diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71594a4..ef24b0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,43 +1,40 @@ name: CI on: push: - branches: - - main - pull_request: - branches: - - main - - next + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: + timeout-minutes: 10 name: lint - runs-on: ubuntu-latest - + runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 - - name: Validate Gradle wrapper - uses: gradle/actions/wrapper-validation@v3 - - name: Set up Java uses: actions/setup-java@v4 with: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v4 - name: Run lints run: ./scripts/lint test: + timeout-minutes: 10 name: test - runs-on: ubuntu-latest - + runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 @@ -47,7 +44,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle @@ -55,4 +52,3 @@ jobs: - name: Run tests run: ./scripts/test - diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 1247fe9..04592b7 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -29,11 +29,13 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Publish to Sonatype - run: | - ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" + 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_ID: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} GPG_SIGNING_KEY: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index f328321..fac0542 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -20,6 +20,5 @@ jobs: env: SONATYPE_USERNAME: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY_ID: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} GPG_SIGNING_KEY: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.gitignore b/.gitignore index 39c31e3..4e81838 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .prism.log .gradle .idea +.kotlin build codegen.log kls_database.db diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1c0bb88..380b6f9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.23" + ".": "0.1.0-alpha.24" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index d4b713b..ad9cf70 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,4 @@ configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-6f08502508c8ad25235971add3124a1cde4f1c3ec705d5df455d750e0adcb90b.yml +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/CHANGELOG.md b/CHANGELOG.md index 6abeafe..ae94241 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## 0.1.0-alpha.24 (2025-07-07) + +Full Changelog: [v0.1.0-alpha.23...v0.1.0-alpha.24](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.23...v0.1.0-alpha.24) + +### Features + +* **api:** api update ([a9266bd](https://github.com/OneBusAway/java-sdk/commit/a9266bd3053952157431e4aee9b36aae6b637164)) +* **api:** manual updates ([#74](https://github.com/OneBusAway/java-sdk/issues/74)) ([ddda17b](https://github.com/OneBusAway/java-sdk/commit/ddda17b7186ef701720740c946250b5fa902a4cc)) + + +### Chores + +* **internal:** codegen related update ([8f6f893](https://github.com/OneBusAway/java-sdk/commit/8f6f893129b9b061d933432fc8ecc36be5e5ad7f)) +* **internal:** codegen related update ([#71](https://github.com/OneBusAway/java-sdk/issues/71)) ([c5e90c0](https://github.com/OneBusAway/java-sdk/commit/c5e90c0cda29a9131fd81e60d22711794a2f0a71)) +* **internal:** codegen related update ([#73](https://github.com/OneBusAway/java-sdk/issues/73)) ([a45c6b0](https://github.com/OneBusAway/java-sdk/commit/a45c6b0bc2f45328c1365db12b9ed2fca0d85ce6)) +* **internal:** codegen related update ([#75](https://github.com/OneBusAway/java-sdk/issues/75)) ([a433a99](https://github.com/OneBusAway/java-sdk/commit/a433a99937fdc1729f36a4e7d16a8d90137758e8)) +* **internal:** codegen related update ([#76](https://github.com/OneBusAway/java-sdk/issues/76)) ([a8f595e](https://github.com/OneBusAway/java-sdk/commit/a8f595e2ee1038f8161ab784fd189d074f375d07)) +* **internal:** codegen related update ([#77](https://github.com/OneBusAway/java-sdk/issues/77)) ([14ea7b7](https://github.com/OneBusAway/java-sdk/commit/14ea7b7438268138410dca70f28807ec06f5c5b0)) +* **internal:** codegen related update ([#78](https://github.com/OneBusAway/java-sdk/issues/78)) ([51a4c8c](https://github.com/OneBusAway/java-sdk/commit/51a4c8cab3782706a773525083c4b17da4543064)) +* **internal:** update example values ([#72](https://github.com/OneBusAway/java-sdk/issues/72)) ([9f7aadf](https://github.com/OneBusAway/java-sdk/commit/9f7aadf0b9229f441f1dbfed4b64035f195c3b1e)) + ## 0.1.0-alpha.23 (2024-11-29) Full Changelog: [v0.1.0-alpha.22...v0.1.0-alpha.23](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.22...v0.1.0-alpha.23) diff --git a/LICENSE b/LICENSE index 9e6f6ec..443d70c 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2024 Onebusaway SDK + Copyright 2025 Onebusaway SDK Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 7dd1dc3..a9ef60f 100644 --- a/README.md +++ b/README.md @@ -2,49 +2,76 @@ -[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.23) +[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.24) +[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.24/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.24) -The Onebusaway SDK Java SDK provides convenient access to the Onebusaway SDK REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property. +The Onebusaway SDK Java SDK provides convenient access to the [Onebusaway SDK REST API](https://developer.onebusaway.org) from applications written in Java. The Onebusaway SDK Java SDK is similar to the Onebusaway SDK Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. -It is generated with [Stainless](https://www.stainlessapi.com/). +It is generated with [Stainless](https://www.stainless.com/). -## Documentation - -The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). - ---- + -## Getting started +The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.24). -### Install dependencies + -#### Gradle +## Installation +### Gradle + ```kotlin -implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.23") +implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.24") ``` -#### Maven +### Maven ```xml - org.onebusaway - onebusaway-sdk-java - 0.1.0-alpha.23 + org.onebusaway + onebusaway-sdk-java + 0.1.0-alpha.24 ``` -### Configure the client +## 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 `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); + +CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(); +``` + +## Client configuration + +Configure the client using environment variables: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); +``` -Use `OnebusawaySdkOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`: +Or manually: ```java import org.onebusaway.client.OnebusawaySdkClient; @@ -55,136 +82,176 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .build(); ``` -Alternately, set the environment with `ONEBUSAWAY_API_KEY`, and use `OnebusawaySdkOkHttpClient.fromEnv()` to read from the environment. +Or using a combination of the two approaches: ```java -OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -// Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + // Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables .fromEnv() - // ... set properties on the builder + .apiKey("My API Key") .build(); ``` -| Property | Environment variable | Required | Default value | -| -------- | -------------------- | -------- | ------------- | -| apiKey | `ONEBUSAWAY_API_KEY` | true | — | +See this table for the available options: -Read the documentation for more configuration options. +| Setter | Environment variable | Required | Default value | +| --------- | ------------------------- | -------- | ----------------------------------------- | +| `apiKey` | `ONEBUSAWAY_API_KEY` | true | - | +| `baseUrl` | `ONEBUSAWAY_SDK_BASE_URL` | true | `"https://api.pugetsound.onebusaway.org"` | ---- +> [!TIP] +> Don't create more than one client in the same application. Each client has a connection pool and +> thread pools, which are more efficient to share between requests. -### Example: creating a resource +## Requests and responses -To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes, -then pass that to the `retrieve` method of the `currentTime` service. +To send a request to the Onebusaway SDK API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -```java -import org.onebusaway.models.CurrentTimeRetrieveParams; -import org.onebusaway.models.CurrentTimeRetrieveResponse; - -CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder().build(); -CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(params); -``` +For example, `client.currentTime().retrieve(...)` should be called with an instance of `CurrentTimeRetrieveParams`, and it will return an instance of `CurrentTimeRetrieveResponse`. ---- +## Immutability -## Requests +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. -### Parameters and bodies +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. -To make a request to the Onebusaway SDK API, you generally build an instance of the appropriate `Params` class. +Because each class is immutable, builder modification will _never_ affect already built class instances. -In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to -the `retrieve` method of the `currentTime` service. +## Asynchronous execution -Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, -you can attach them using the `putAdditionalProperty` method. +The default client is synchronous. To switch to asynchronous execution, call the `async()` method: ```java -import org.onebusaway.models.core.JsonValue; -CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder() - // ... normal properties - .putAdditionalProperty("secret_param", JsonValue.from("4242")) - .build(); -``` +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; -## Responses +// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); -### Response validation +CompletableFuture currentTime = client.async().currentTime().retrieve(); +``` -When receiving a response, the Onebusaway SDK Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `OnebusawaySdkInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model. +Or create an asynchronous client from the beginning: ```java -CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve().validate(); +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 `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClientAsync client = OnebusawaySdkOkHttpClientAsync.fromEnv(); + +CompletableFuture currentTime = client.currentTime().retrieve(); ``` -### Response properties as JSON +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. -In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by -this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value. +## Raw responses + +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 -JsonField field = responseObj._field(); +import org.onebusaway.core.http.Headers; +import org.onebusaway.core.http.HttpResponseFor; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; -if (field.isMissing()) { - // Value was not specified in the JSON response -} else if (field.isNull()) { - // Value was provided as a literal null -} else { - // See if value was provided as a string - Optional jsonString = field.asString(); +HttpResponseFor currentTime = client.currentTime().withRawResponse().retrieve(); - // If the value given by the API did not match the shape that the SDK expects - // you can deserialise into a custom type - MyClass myObj = responseObj._field().asUnknown().orElseThrow().convert(MyClass.class); -} +int statusCode = currentTime.statusCode(); +Headers headers = currentTime.headers(); ``` -### Additional model properties - -Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method: +You can still deserialize the response into an instance of a Java class if needed: ```java -JsonValue secret = references._additionalProperties().get("secret_field"); +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; + +CurrentTimeRetrieveResponse parsedCurrentTime = currentTime.parse(); ``` ---- +## Error handling ---- +The SDK throws custom unchecked exception types: -## Error handling +- [`OnebusawaySdkServiceException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: -This library throws exceptions in a single hierarchy for easy handling: + | Status | Exception | + | ------ | ---------------------------------------------------------------------------------------------------------------------------------- | + | 400 | [`BadRequestException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt) | + | 401 | [`UnauthorizedException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt) | + | 403 | [`PermissionDeniedException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt) | + | 404 | [`NotFoundException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt) | + | 422 | [`UnprocessableEntityException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt) | + | 429 | [`RateLimitException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt) | + | 5xx | [`InternalServerException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt) | + | others | [`UnexpectedStatusCodeException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt) | + +- [`OnebusawaySdkIoException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkIoException.kt): I/O networking errors. + +- [`OnebusawaySdkInvalidDataException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. + +- [`OnebusawaySdkException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. + +## Logging + +The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). + +Enable logging by setting the `ONEBUSAWAY_SDK_LOG` environment variable to `info`: + +```sh +$ export ONEBUSAWAY_SDK_LOG=info +``` + +Or to `debug` for more verbose logging: + +```sh +$ export ONEBUSAWAY_SDK_LOG=debug +``` -- **`OnebusawaySdkException`** - Base exception for all exceptions +## Jackson - - **`OnebusawaySdkServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server. +The SDK 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. - | 400 | BadRequestException | - | ------ | ----------------------------- | - | 401 | AuthenticationException | - | 403 | PermissionDeniedException | - | 404 | NotFoundException | - | 422 | UnprocessableEntityException | - | 429 | RateLimitException | - | 5xx | InternalServerException | - | others | UnexpectedStatusCodeException | +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). - - **`OnebusawaySdkIoException`** - I/O networking errors - - **`OnebusawaySdkInvalidDataException`** - any other exceptions on the client side, e.g.: - - We failed to serialize the request body - - We failed to parse the response body (has access to response code and body) +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 -Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. -You can provide a `maxRetries` on the client builder to configure this: +The SDK automatically retries 2 times by default, with a short exponential backoff. + +Only the following error types are retried: + +- Connection errors (for example, due to a network connectivity problem) +- 408 Request Timeout +- 409 Conflict +- 429 Rate Limit +- 5xx Internal + +The API may also explicitly instruct the SDK to retry or not retry a response. + +To set a custom number of retries, configure the client using the `maxRetries` method: ```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .fromEnv() .maxRetries(4) @@ -193,9 +260,23 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() ### Timeouts -Requests time out after 1 minute by default. You can configure this on the client builder: +Requests time out after 1 minute by default. + +To set a custom timeout, configure the method call using the `timeout` method: ```java +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; + +CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); +``` + +Or configure the default for all method calls at the client level: + +```java +import java.time.Duration; +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .fromEnv() .timeout(Duration.ofSeconds(30)) @@ -204,53 +285,266 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() ### Proxies -Requests can be routed through a proxy. You can configure this on the client builder: +To route requests through a proxy, configure the client using the `proxy` method: ```java +import java.net.InetSocketAddress; +import java.net.Proxy; +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .fromEnv() .proxy(new Proxy( - Type.HTTP, - new InetSocketAddress("proxy.com", 8080) + Proxy.Type.HTTP, new InetSocketAddress( + "https://example.com", 8080 + ) )) .build(); ``` -## Making custom/undocumented requests +### Custom HTTP client -This library is typed for convenient access to the documented API. If you need to access undocumented -params or response properties, the library can still be used. +The SDK consists of three artifacts: -### Undocumented request params +- `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 -To make requests using undocumented parameters, you can provide or override parameters on the params object -while building it. +This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies. -```kotlin -FooCreateParams address = FooCreateParams.builder() - .id("my_id") - .putAdditionalProperty("secret_prop", JsonValue.from("hello")) +#### 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(); ``` -### Undocumented response properties +### 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; -To access undocumented response properties, you can use `res._additionalProperties()` on a response object to -get a map of untyped fields of type `Map`. You can then access fields like -`._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class -to extract it to a desired type. +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)_. +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ 2. Changes that we do not expect to impact the vast majority of users in practice. We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. We are keen for your feedback; please open an [issue](https://www.github.com/OneBusAway/java-sdk/issues) with questions, bugs, or suggestions. - -## Requirements - -This library requires Java 8 or later. diff --git a/SECURITY.md b/SECURITY.md index 62ac016..8be07dc 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,9 @@ ## Reporting Security Issues -This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. -To report a security issue, please contact the Stainless team at security@stainlessapi.com. +To report a security issue, please contact the Stainless team at security@stainless.com. ## Responsible Disclosure diff --git a/build.gradle.kts b/build.gradle.kts index 8c8ea48..a036b20 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,23 @@ plugins { + id("org.jetbrains.dokka") version "2.0.0" +} +repositories { + mavenCentral() } allprojects { group = "org.onebusaway" - version = "0.1.0-alpha.23" // x-release-please-version + version = "0.1.0-alpha.24" // x-release-please-version } +subprojects { + apply(plugin = "org.jetbrains.dokka") +} +// Avoid race conditions between `dokkaJavadocCollector` and `dokkaJavadocJar` tasks +tasks.named("dokkaJavadocCollector").configure { + subprojects.flatMap { it.tasks } + .filter { it.project.name != "onebusaway-sdk-java" && it.name == "dokkaJavadocJar" } + .forEach { mustRunAfter(it) } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 493cb32..778c89d 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `kotlin-dsl` - kotlin("jvm") version "1.9.22" + kotlin("jvm") version "1.9.20" id("com.vanniktech.maven.publish") version "0.28.0" } @@ -10,7 +10,7 @@ repositories { } dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23") + implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts index 32a150e..dfbacb8 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts @@ -1,9 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar -import com.vanniktech.maven.publish.MavenPublishBaseExtension -import com.vanniktech.maven.publish.SonatypeHost plugins { `java-library` @@ -25,8 +21,11 @@ configure { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } tasks.withType().configureEach { @@ -43,9 +42,13 @@ tasks.named("jar") { } } -tasks.named("test") { +tasks.withType().configureEach { useJUnitPlatform() + // Run tests in parallel to some degree. + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 + testLogging { exceptionFormat = TestExceptionFormat.FULL } diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts index 6da1ac7..be0b5d4 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts @@ -1,6 +1,6 @@ import com.diffplug.gradle.spotless.SpotlessExtension -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import com.vanniktech.maven.publish.* +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion plugins { id("onebusaway-sdk.java") @@ -9,7 +9,21 @@ plugins { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) + } + + compilerOptions { + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. + "-nowarn", + ) + jvmTarget.set(JvmTarget.JVM_1_8) + languageVersion.set(KotlinVersion.KOTLIN_1_8) + apiVersion.set(KotlinVersion.KOTLIN_1_8) + coreLibrariesVersion = "1.8.0" } } @@ -20,10 +34,7 @@ configure { } } -tasks.withType().configureEach { - kotlinOptions { - allWarningsAsErrors = true - freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=1.8") - jvmTarget = "1.8" - } +tasks.withType().configureEach { + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") } diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts index 4c6d7fa..8ba555d 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts @@ -1,10 +1,5 @@ -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.get -import com.vanniktech.maven.publish.JavaLibrary import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinJvm import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost @@ -25,7 +20,13 @@ configure { signAllPublications() publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - this.coordinates(project.group.toString(), project.name, project.version.toString()) + coordinates(project.group.toString(), project.name, project.version.toString()) + configure( + KotlinJvm( + javadocJar = JavadocJar.Dokka("dokkaJavadoc"), + sourcesJar = true, + ) + ) pom { name.set("OneBusAway") diff --git a/gradle.properties b/gradle.properties index a3bc58f..ff76593 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,17 @@ org.gradle.caching=true -org.gradle.jvmargs=-Xmx4g +org.gradle.configuration-cache=true org.gradle.parallel=true -kotlin.daemon.jvmargs=-Xmx4g +org.gradle.daemon=false +# These options improve our compilation and test performance. They are inherited by the Kotlin daemon. +org.gradle.jvmargs=\ + -Xms1g \ + -Xmx4g \ + -XX:+UseParallelGC \ + -XX:InitialCodeCacheSize=256m \ + -XX:ReservedCodeCacheSize=1G \ + -XX:MetaspaceSize=256m \ + -XX:TieredStopAtLevel=1 \ + -XX:GCTimeRatio=4 \ + -XX:CICompilerCount=4 \ + -XX:+OptimizeStringConcat \ + -XX:+UseStringDeduplication diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e644113..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23..cea7a79 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..f3b75f3 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30d..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/onebusaway-sdk-java-client-okhttp/build.gradle.kts b/onebusaway-sdk-java-client-okhttp/build.gradle.kts index 037ef81..2fd0abf 100644 --- a/onebusaway-sdk-java-client-okhttp/build.gradle.kts +++ b/onebusaway-sdk-java-client-okhttp/build.gradle.kts @@ -6,10 +6,9 @@ plugins { dependencies { api(project(":onebusaway-sdk-java-core")) - implementation("com.google.guava:guava:33.0.0-jre") implementation("com.squareup.okhttp3:okhttp:4.12.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.25.3") - testImplementation("org.slf4j:slf4j-simple:2.0.12") } diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt index 427df17..32d8d5e 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt @@ -1,7 +1,5 @@ package org.onebusaway.client.okhttp -import com.google.common.collect.ListMultimap -import com.google.common.collect.MultimapBuilder import java.io.IOException import java.io.InputStream import java.net.Proxy @@ -9,17 +7,21 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.Headers import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.Interceptor 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.checkRequired +import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest @@ -31,22 +33,8 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { - val timeout = requestOptions.timeout ?: return okHttpClient - return okHttpClient - .newBuilder() - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) - .build() - } - - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { - val call = getClient(requestOptions).newCall(request.toRequest()) + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val call = newCall(request, requestOptions) return try { call.execute().toResponse() @@ -65,18 +53,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } - val call = getClient(requestOptions).newCall(request.toRequest()) - call.enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(OnebusawaySdkIoException("Request failed", e)) + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(OnebusawaySdkIoException("Request failed", e)) + } } - } - ) + ) return future } @@ -87,19 +75,72 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val okHttpClient.cache?.close() } - private fun HttpRequest.toRequest(): Request { + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + val clientBuilder = okHttpClient.newBuilder() + + // Custom logging interceptor for URL logging + clientBuilder.addNetworkInterceptor(LoggingInterceptor()) + + val logLevel = + when (System.getenv("ONEBUSAWAY_SDK_LOG")?.lowercase()) { + "info" -> HttpLoggingInterceptor.Level.BASIC + "debug" -> HttpLoggingInterceptor.Level.BODY + else -> null + } + if (logLevel != null) { + clientBuilder.addNetworkInterceptor(HttpLoggingInterceptor().setLevel(logLevel)) + } + + 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() - // OkHttpClient always requires a request body for PUT and POST methods. - if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) { + if (body == null && requiresBody(method)) { body = "".toRequestBody() } val builder = Request.Builder().url(toUrl()).method(method.name, body) - headers.forEach(builder::header) + headers.names().forEach { name -> + headers.values(name).forEach { builder.header(name, it) } + } + + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.header( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.header( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } return builder.build() } + /** `OkHttpClient` always requires a request body for some methods. */ + private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + private fun HttpRequest.toUrl(): String { url?.let { return it @@ -107,7 +148,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val val builder = baseUrl.newBuilder() pathSegments.forEach(builder::addPathSegment) - queryParams.forEach(builder::addQueryParameter) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } return builder.toString() } @@ -133,7 +176,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val return object : HttpResponse { override fun statusCode(): Int = code - override fun headers(): ListMultimap = headers + override fun headers(): Headers = headers override fun body(): InputStream = body!!.byteStream() @@ -141,42 +184,51 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } } - private fun Headers.toHeaders(): ListMultimap { - val headers = - MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) - .arrayListValues() - .build() - forEach { pair -> headers.put(pair.first, pair.second) } - return headers + private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() } companion object { @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var baseUrl: HttpUrl? = null - // The default timeout is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) .proxy(proxy) .build(), - checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }, + checkRequired("baseUrl", baseUrl), ) } } + +// --- ✅ New class added below --- +class LoggingInterceptor : Interceptor { + override fun intercept(chain: Interceptor.Chain): Response { + val request = chain.request() + println("➡️ Sending request: ${request.method} ${request.url}") + val response = chain.proceed(request) + println("⬅️ Received response: ${response.code} ${response.request.url}") + return response + } +} diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt index 4c71daa..1c947e1 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt @@ -9,33 +9,48 @@ import java.time.Duration import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.OnebusawaySdkClientImpl import org.onebusaway.core.ClientOptions +import org.onebusaway.core.Timeout +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams class OnebusawaySdkOkHttpClient private constructor() { companion object { + /** + * Returns a mutable builder for constructing an instance of [OnebusawaySdkOkHttpClient]. + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): OnebusawaySdkClient = builder().fromEnv().build() } - class Builder { + /** A builder for [OnebusawaySdkOkHttpClient]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + fun headers(headers: Map>) = apply { clientOptions.headers(headers) } @@ -46,6 +61,8 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.putHeaders(name, values) } + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + fun putAllHeaders(headers: Map>) = apply { clientOptions.putAllHeaders(headers) } @@ -58,6 +75,8 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.replaceHeaders(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + fun replaceAllHeaders(headers: Map>) = apply { clientOptions.replaceAllHeaders(headers) } @@ -66,6 +85,8 @@ class OnebusawaySdkOkHttpClient private constructor() { fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + fun queryParams(queryParams: Map>) = apply { clientOptions.queryParams(queryParams) } @@ -78,6 +99,10 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.putQueryParams(key, values) } + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + fun putAllQueryParams(queryParams: Map>) = apply { clientOptions.putAllQueryParams(queryParams) } @@ -90,6 +115,10 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.replaceQueryParams(key, values) } + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + fun replaceAllQueryParams(queryParams: Map>) = apply { clientOptions.replaceAllQueryParams(queryParams) } @@ -100,7 +129,19 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } @@ -114,12 +155,17 @@ class OnebusawaySdkOkHttpClient private constructor() { fun fromEnv() = apply { clientOptions.fromEnv() } + /** + * Returns an immutable instance of [OnebusawaySdkClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OnebusawaySdkClient = OnebusawaySdkClientImpl( clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt index 00ea3d2..40b84fd 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt @@ -9,33 +9,49 @@ import java.time.Duration import org.onebusaway.client.OnebusawaySdkClientAsync import org.onebusaway.client.OnebusawaySdkClientAsyncImpl import org.onebusaway.core.ClientOptions +import org.onebusaway.core.Timeout +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams class OnebusawaySdkOkHttpClientAsync private constructor() { companion object { + /** + * Returns a mutable builder for constructing an instance of + * [OnebusawaySdkOkHttpClientAsync]. + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): OnebusawaySdkClientAsync = builder().fromEnv().build() } - class Builder { + /** A builder for [OnebusawaySdkOkHttpClientAsync]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + fun headers(headers: Map>) = apply { clientOptions.headers(headers) } @@ -46,6 +62,8 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.putHeaders(name, values) } + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + fun putAllHeaders(headers: Map>) = apply { clientOptions.putAllHeaders(headers) } @@ -58,6 +76,8 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.replaceHeaders(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + fun replaceAllHeaders(headers: Map>) = apply { clientOptions.replaceAllHeaders(headers) } @@ -66,6 +86,8 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + fun queryParams(queryParams: Map>) = apply { clientOptions.queryParams(queryParams) } @@ -78,6 +100,10 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.putQueryParams(key, values) } + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + fun putAllQueryParams(queryParams: Map>) = apply { clientOptions.putAllQueryParams(queryParams) } @@ -90,6 +116,10 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.replaceQueryParams(key, values) } + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + fun replaceAllQueryParams(queryParams: Map>) = apply { clientOptions.replaceAllQueryParams(queryParams) } @@ -100,7 +130,19 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } @@ -114,12 +156,17 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { fun fromEnv() = apply { clientOptions.fromEnv() } + /** + * Returns an immutable instance of [OnebusawaySdkClientAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OnebusawaySdkClientAsync = OnebusawaySdkClientAsyncImpl( clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() diff --git a/onebusaway-sdk-java-core/build.gradle.kts b/onebusaway-sdk-java-core/build.gradle.kts index 8f52193..c020c89 100644 --- a/onebusaway-sdk-java-core/build.gradle.kts +++ b/onebusaway-sdk-java-core/build.gradle.kts @@ -3,15 +3,28 @@ plugins { id("onebusaway-sdk.publish") } +configurations.all { + resolutionStrategy { + // Compile and test against a lower Jackson version to ensure we're compatible with it. + // We publish with a higher version (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.13.4") + force("com.fasterxml.jackson.core:jackson-databind:2.13.4") + force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + } +} + dependencies { - api("com.fasterxml.jackson.core:jackson-core:2.14.3") - api("com.fasterxml.jackson.core:jackson-databind:2.14.3") - api("com.google.guava:guava:33.0.0-jre") + api("com.fasterxml.jackson.core:jackson-core:2.18.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.14.3") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.3") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3") + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.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") @@ -19,8 +32,10 @@ dependencies { testImplementation(project(":onebusaway-sdk-java-client-okhttp")) testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") testImplementation("org.assertj:assertj-core:3.25.3") - testImplementation("org.assertj:assertj-guava:3.25.3") - testImplementation("org.slf4j:slf4j-simple:2.0.12") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") + testImplementation("org.mockito:mockito-core:5.14.2") + testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") + testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt index 44afaea..6128438 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt @@ -2,13 +2,64 @@ package org.onebusaway.client -import org.onebusaway.models.* -import org.onebusaway.services.blocking.* - +import org.onebusaway.services.blocking.AgenciesWithCoverageService +import org.onebusaway.services.blocking.AgencyService +import org.onebusaway.services.blocking.ArrivalAndDepartureService +import org.onebusaway.services.blocking.BlockService +import org.onebusaway.services.blocking.ConfigService +import org.onebusaway.services.blocking.CurrentTimeService +import org.onebusaway.services.blocking.ReportProblemWithStopService +import org.onebusaway.services.blocking.ReportProblemWithTripService +import org.onebusaway.services.blocking.RouteIdsForAgencyService +import org.onebusaway.services.blocking.RouteService +import org.onebusaway.services.blocking.RoutesForAgencyService +import org.onebusaway.services.blocking.RoutesForLocationService +import org.onebusaway.services.blocking.ScheduleForRouteService +import org.onebusaway.services.blocking.ScheduleForStopService +import org.onebusaway.services.blocking.SearchForRouteService +import org.onebusaway.services.blocking.SearchForStopService +import org.onebusaway.services.blocking.ShapeService +import org.onebusaway.services.blocking.StopIdsForAgencyService +import org.onebusaway.services.blocking.StopService +import org.onebusaway.services.blocking.StopsForAgencyService +import org.onebusaway.services.blocking.StopsForLocationService +import org.onebusaway.services.blocking.StopsForRouteService +import org.onebusaway.services.blocking.TripDetailService +import org.onebusaway.services.blocking.TripForVehicleService +import org.onebusaway.services.blocking.TripService +import org.onebusaway.services.blocking.TripsForLocationService +import org.onebusaway.services.blocking.TripsForRouteService +import org.onebusaway.services.blocking.VehiclesForAgencyService + +/** + * 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 + fun agenciesWithCoverage(): AgenciesWithCoverageService fun agency(): AgencyService @@ -64,4 +115,79 @@ interface OnebusawaySdkClient { fun block(): BlockService fun shape(): ShapeService + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** + * A view of [OnebusawaySdkClient] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun agenciesWithCoverage(): AgenciesWithCoverageService.WithRawResponse + + fun agency(): AgencyService.WithRawResponse + + fun vehiclesForAgency(): VehiclesForAgencyService.WithRawResponse + + fun config(): ConfigService.WithRawResponse + + fun currentTime(): CurrentTimeService.WithRawResponse + + fun stopsForLocation(): StopsForLocationService.WithRawResponse + + fun stopsForRoute(): StopsForRouteService.WithRawResponse + + fun stopsForAgency(): StopsForAgencyService.WithRawResponse + + fun stop(): StopService.WithRawResponse + + fun stopIdsForAgency(): StopIdsForAgencyService.WithRawResponse + + fun scheduleForStop(): ScheduleForStopService.WithRawResponse + + fun route(): RouteService.WithRawResponse + + fun routeIdsForAgency(): RouteIdsForAgencyService.WithRawResponse + + fun routesForLocation(): RoutesForLocationService.WithRawResponse + + fun routesForAgency(): RoutesForAgencyService.WithRawResponse + + fun scheduleForRoute(): ScheduleForRouteService.WithRawResponse + + fun arrivalAndDeparture(): ArrivalAndDepartureService.WithRawResponse + + fun trip(): TripService.WithRawResponse + + fun tripsForLocation(): TripsForLocationService.WithRawResponse + + fun tripDetails(): TripDetailService.WithRawResponse + + fun tripForVehicle(): TripForVehicleService.WithRawResponse + + fun tripsForRoute(): TripsForRouteService.WithRawResponse + + fun reportProblemWithStop(): ReportProblemWithStopService.WithRawResponse + + fun reportProblemWithTrip(): ReportProblemWithTripService.WithRawResponse + + fun searchForStop(): SearchForStopService.WithRawResponse + + fun searchForRoute(): SearchForRouteService.WithRawResponse + + fun block(): BlockService.WithRawResponse + + fun shape(): ShapeService.WithRawResponse + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt index 0029e0f..df8c27f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt @@ -2,13 +2,64 @@ package org.onebusaway.client -import org.onebusaway.models.* -import org.onebusaway.services.async.* - +import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync +import org.onebusaway.services.async.AgencyServiceAsync +import org.onebusaway.services.async.ArrivalAndDepartureServiceAsync +import org.onebusaway.services.async.BlockServiceAsync +import org.onebusaway.services.async.ConfigServiceAsync +import org.onebusaway.services.async.CurrentTimeServiceAsync +import org.onebusaway.services.async.ReportProblemWithStopServiceAsync +import org.onebusaway.services.async.ReportProblemWithTripServiceAsync +import org.onebusaway.services.async.RouteIdsForAgencyServiceAsync +import org.onebusaway.services.async.RouteServiceAsync +import org.onebusaway.services.async.RoutesForAgencyServiceAsync +import org.onebusaway.services.async.RoutesForLocationServiceAsync +import org.onebusaway.services.async.ScheduleForRouteServiceAsync +import org.onebusaway.services.async.ScheduleForStopServiceAsync +import org.onebusaway.services.async.SearchForRouteServiceAsync +import org.onebusaway.services.async.SearchForStopServiceAsync +import org.onebusaway.services.async.ShapeServiceAsync +import org.onebusaway.services.async.StopIdsForAgencyServiceAsync +import org.onebusaway.services.async.StopServiceAsync +import org.onebusaway.services.async.StopsForAgencyServiceAsync +import org.onebusaway.services.async.StopsForLocationServiceAsync +import org.onebusaway.services.async.StopsForRouteServiceAsync +import org.onebusaway.services.async.TripDetailServiceAsync +import org.onebusaway.services.async.TripForVehicleServiceAsync +import org.onebusaway.services.async.TripServiceAsync +import org.onebusaway.services.async.TripsForLocationServiceAsync +import org.onebusaway.services.async.TripsForRouteServiceAsync +import org.onebusaway.services.async.VehiclesForAgencyServiceAsync + +/** + * 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 + fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync fun agency(): AgencyServiceAsync @@ -64,4 +115,80 @@ interface OnebusawaySdkClientAsync { fun block(): BlockServiceAsync fun shape(): ShapeServiceAsync + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** + * A view of [OnebusawaySdkClientAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse + + fun agency(): AgencyServiceAsync.WithRawResponse + + fun vehiclesForAgency(): VehiclesForAgencyServiceAsync.WithRawResponse + + fun config(): ConfigServiceAsync.WithRawResponse + + fun currentTime(): CurrentTimeServiceAsync.WithRawResponse + + fun stopsForLocation(): StopsForLocationServiceAsync.WithRawResponse + + fun stopsForRoute(): StopsForRouteServiceAsync.WithRawResponse + + fun stopsForAgency(): StopsForAgencyServiceAsync.WithRawResponse + + fun stop(): StopServiceAsync.WithRawResponse + + fun stopIdsForAgency(): StopIdsForAgencyServiceAsync.WithRawResponse + + fun scheduleForStop(): ScheduleForStopServiceAsync.WithRawResponse + + fun route(): RouteServiceAsync.WithRawResponse + + fun routeIdsForAgency(): RouteIdsForAgencyServiceAsync.WithRawResponse + + fun routesForLocation(): RoutesForLocationServiceAsync.WithRawResponse + + fun routesForAgency(): RoutesForAgencyServiceAsync.WithRawResponse + + fun scheduleForRoute(): ScheduleForRouteServiceAsync.WithRawResponse + + fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync.WithRawResponse + + fun trip(): TripServiceAsync.WithRawResponse + + fun tripsForLocation(): TripsForLocationServiceAsync.WithRawResponse + + fun tripDetails(): TripDetailServiceAsync.WithRawResponse + + fun tripForVehicle(): TripForVehicleServiceAsync.WithRawResponse + + fun tripsForRoute(): TripsForRouteServiceAsync.WithRawResponse + + fun reportProblemWithStop(): ReportProblemWithStopServiceAsync.WithRawResponse + + fun reportProblemWithTrip(): ReportProblemWithTripServiceAsync.WithRawResponse + + fun searchForStop(): SearchForStopServiceAsync.WithRawResponse + + fun searchForRoute(): SearchForRouteServiceAsync.WithRawResponse + + fun block(): BlockServiceAsync.WithRawResponse + + fun shape(): ShapeServiceAsync.WithRawResponse + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt index f930dc9..b03336a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt @@ -4,16 +4,68 @@ package org.onebusaway.client import org.onebusaway.core.ClientOptions import org.onebusaway.core.getPackageVersion -import org.onebusaway.models.* -import org.onebusaway.services.async.* - -class OnebusawaySdkClientAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : OnebusawaySdkClientAsync { +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.containsKey("User-Agent")) clientOptions + if (clientOptions.headers.names().contains("User-Agent")) clientOptions else clientOptions .toBuilder() @@ -23,6 +75,10 @@ constructor( // 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) } @@ -133,6 +189,8 @@ constructor( override fun sync(): OnebusawaySdkClient = sync + override fun withRawResponse(): OnebusawaySdkClientAsync.WithRawResponse = withRawResponse + override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync = agenciesWithCoverage override fun agency(): AgencyServiceAsync = agency @@ -188,4 +246,193 @@ constructor( override fun block(): BlockServiceAsync = block override fun shape(): ShapeServiceAsync = shape + + override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OnebusawaySdkClientAsync.WithRawResponse { + + private val agenciesWithCoverage: AgenciesWithCoverageServiceAsync.WithRawResponse by lazy { + AgenciesWithCoverageServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val agency: AgencyServiceAsync.WithRawResponse by lazy { + AgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val vehiclesForAgency: VehiclesForAgencyServiceAsync.WithRawResponse by lazy { + VehiclesForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val config: ConfigServiceAsync.WithRawResponse by lazy { + ConfigServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val currentTime: CurrentTimeServiceAsync.WithRawResponse by lazy { + CurrentTimeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForLocation: StopsForLocationServiceAsync.WithRawResponse by lazy { + StopsForLocationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForRoute: StopsForRouteServiceAsync.WithRawResponse by lazy { + StopsForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForAgency: StopsForAgencyServiceAsync.WithRawResponse by lazy { + StopsForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stop: StopServiceAsync.WithRawResponse by lazy { + StopServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stopIdsForAgency: StopIdsForAgencyServiceAsync.WithRawResponse by lazy { + StopIdsForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val scheduleForStop: ScheduleForStopServiceAsync.WithRawResponse by lazy { + ScheduleForStopServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val route: RouteServiceAsync.WithRawResponse by lazy { + RouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val routeIdsForAgency: RouteIdsForAgencyServiceAsync.WithRawResponse by lazy { + RouteIdsForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val routesForLocation: RoutesForLocationServiceAsync.WithRawResponse by lazy { + RoutesForLocationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val routesForAgency: RoutesForAgencyServiceAsync.WithRawResponse by lazy { + RoutesForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val scheduleForRoute: ScheduleForRouteServiceAsync.WithRawResponse by lazy { + ScheduleForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val arrivalAndDeparture: ArrivalAndDepartureServiceAsync.WithRawResponse by lazy { + ArrivalAndDepartureServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val trip: TripServiceAsync.WithRawResponse by lazy { + TripServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tripsForLocation: TripsForLocationServiceAsync.WithRawResponse by lazy { + TripsForLocationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tripDetails: TripDetailServiceAsync.WithRawResponse by lazy { + TripDetailServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tripForVehicle: TripForVehicleServiceAsync.WithRawResponse by lazy { + TripForVehicleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tripsForRoute: TripsForRouteServiceAsync.WithRawResponse by lazy { + TripsForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val reportProblemWithStop: + ReportProblemWithStopServiceAsync.WithRawResponse by lazy { + ReportProblemWithStopServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val reportProblemWithTrip: + ReportProblemWithTripServiceAsync.WithRawResponse by lazy { + ReportProblemWithTripServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val searchForStop: SearchForStopServiceAsync.WithRawResponse by lazy { + SearchForStopServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val searchForRoute: SearchForRouteServiceAsync.WithRawResponse by lazy { + SearchForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val block: BlockServiceAsync.WithRawResponse by lazy { + BlockServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val shape: ShapeServiceAsync.WithRawResponse by lazy { + ShapeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse = + agenciesWithCoverage + + override fun agency(): AgencyServiceAsync.WithRawResponse = agency + + override fun vehiclesForAgency(): VehiclesForAgencyServiceAsync.WithRawResponse = + vehiclesForAgency + + override fun config(): ConfigServiceAsync.WithRawResponse = config + + override fun currentTime(): CurrentTimeServiceAsync.WithRawResponse = currentTime + + override fun stopsForLocation(): StopsForLocationServiceAsync.WithRawResponse = + stopsForLocation + + override fun stopsForRoute(): StopsForRouteServiceAsync.WithRawResponse = stopsForRoute + + override fun stopsForAgency(): StopsForAgencyServiceAsync.WithRawResponse = stopsForAgency + + override fun stop(): StopServiceAsync.WithRawResponse = stop + + override fun stopIdsForAgency(): StopIdsForAgencyServiceAsync.WithRawResponse = + stopIdsForAgency + + override fun scheduleForStop(): ScheduleForStopServiceAsync.WithRawResponse = + scheduleForStop + + override fun route(): RouteServiceAsync.WithRawResponse = route + + override fun routeIdsForAgency(): RouteIdsForAgencyServiceAsync.WithRawResponse = + routeIdsForAgency + + override fun routesForLocation(): RoutesForLocationServiceAsync.WithRawResponse = + routesForLocation + + override fun routesForAgency(): RoutesForAgencyServiceAsync.WithRawResponse = + routesForAgency + + override fun scheduleForRoute(): ScheduleForRouteServiceAsync.WithRawResponse = + scheduleForRoute + + override fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync.WithRawResponse = + arrivalAndDeparture + + override fun trip(): TripServiceAsync.WithRawResponse = trip + + override fun tripsForLocation(): TripsForLocationServiceAsync.WithRawResponse = + tripsForLocation + + override fun tripDetails(): TripDetailServiceAsync.WithRawResponse = tripDetails + + override fun tripForVehicle(): TripForVehicleServiceAsync.WithRawResponse = tripForVehicle + + override fun tripsForRoute(): TripsForRouteServiceAsync.WithRawResponse = tripsForRoute + + override fun reportProblemWithStop(): ReportProblemWithStopServiceAsync.WithRawResponse = + reportProblemWithStop + + override fun reportProblemWithTrip(): ReportProblemWithTripServiceAsync.WithRawResponse = + reportProblemWithTrip + + override fun searchForStop(): SearchForStopServiceAsync.WithRawResponse = searchForStop + + override fun searchForRoute(): SearchForRouteServiceAsync.WithRawResponse = searchForRoute + + override fun block(): BlockServiceAsync.WithRawResponse = block + + override fun shape(): ShapeServiceAsync.WithRawResponse = shape + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt index 1183849..b3213c5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt @@ -4,16 +4,67 @@ package org.onebusaway.client import org.onebusaway.core.ClientOptions import org.onebusaway.core.getPackageVersion -import org.onebusaway.models.* -import org.onebusaway.services.blocking.* - -class OnebusawaySdkClientImpl -constructor( - private val clientOptions: ClientOptions, -) : OnebusawaySdkClient { +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.containsKey("User-Agent")) clientOptions + if (clientOptions.headers.names().contains("User-Agent")) clientOptions else clientOptions .toBuilder() @@ -25,6 +76,10 @@ constructor( OnebusawaySdkClientAsyncImpl(clientOptions) } + private val withRawResponse: OnebusawaySdkClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val agenciesWithCoverage: AgenciesWithCoverageService by lazy { AgenciesWithCoverageServiceImpl(clientOptionsWithUserAgent) } @@ -125,6 +180,8 @@ constructor( override fun async(): OnebusawaySdkClientAsync = async + override fun withRawResponse(): OnebusawaySdkClient.WithRawResponse = withRawResponse + override fun agenciesWithCoverage(): AgenciesWithCoverageService = agenciesWithCoverage override fun agency(): AgencyService = agency @@ -180,4 +237,185 @@ constructor( override fun block(): BlockService = block override fun shape(): ShapeService = shape + + override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OnebusawaySdkClient.WithRawResponse { + + private val agenciesWithCoverage: AgenciesWithCoverageService.WithRawResponse by lazy { + AgenciesWithCoverageServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val agency: AgencyService.WithRawResponse by lazy { + AgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val vehiclesForAgency: VehiclesForAgencyService.WithRawResponse by lazy { + VehiclesForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val config: ConfigService.WithRawResponse by lazy { + ConfigServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val currentTime: CurrentTimeService.WithRawResponse by lazy { + CurrentTimeServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForLocation: StopsForLocationService.WithRawResponse by lazy { + StopsForLocationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForRoute: StopsForRouteService.WithRawResponse by lazy { + StopsForRouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForAgency: StopsForAgencyService.WithRawResponse by lazy { + StopsForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stop: StopService.WithRawResponse by lazy { + StopServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stopIdsForAgency: StopIdsForAgencyService.WithRawResponse by lazy { + StopIdsForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val scheduleForStop: ScheduleForStopService.WithRawResponse by lazy { + ScheduleForStopServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val route: RouteService.WithRawResponse by lazy { + RouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val routeIdsForAgency: RouteIdsForAgencyService.WithRawResponse by lazy { + RouteIdsForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val routesForLocation: RoutesForLocationService.WithRawResponse by lazy { + RoutesForLocationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val routesForAgency: RoutesForAgencyService.WithRawResponse by lazy { + RoutesForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val scheduleForRoute: ScheduleForRouteService.WithRawResponse by lazy { + ScheduleForRouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val arrivalAndDeparture: ArrivalAndDepartureService.WithRawResponse by lazy { + ArrivalAndDepartureServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val trip: TripService.WithRawResponse by lazy { + TripServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tripsForLocation: TripsForLocationService.WithRawResponse by lazy { + TripsForLocationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tripDetails: TripDetailService.WithRawResponse by lazy { + TripDetailServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tripForVehicle: TripForVehicleService.WithRawResponse by lazy { + TripForVehicleServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tripsForRoute: TripsForRouteService.WithRawResponse by lazy { + TripsForRouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val reportProblemWithStop: ReportProblemWithStopService.WithRawResponse by lazy { + ReportProblemWithStopServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val reportProblemWithTrip: ReportProblemWithTripService.WithRawResponse by lazy { + ReportProblemWithTripServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val searchForStop: SearchForStopService.WithRawResponse by lazy { + SearchForStopServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val searchForRoute: SearchForRouteService.WithRawResponse by lazy { + SearchForRouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val block: BlockService.WithRawResponse by lazy { + BlockServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val shape: ShapeService.WithRawResponse by lazy { + ShapeServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun agenciesWithCoverage(): AgenciesWithCoverageService.WithRawResponse = + agenciesWithCoverage + + override fun agency(): AgencyService.WithRawResponse = agency + + override fun vehiclesForAgency(): VehiclesForAgencyService.WithRawResponse = + vehiclesForAgency + + override fun config(): ConfigService.WithRawResponse = config + + override fun currentTime(): CurrentTimeService.WithRawResponse = currentTime + + override fun stopsForLocation(): StopsForLocationService.WithRawResponse = stopsForLocation + + override fun stopsForRoute(): StopsForRouteService.WithRawResponse = stopsForRoute + + override fun stopsForAgency(): StopsForAgencyService.WithRawResponse = stopsForAgency + + override fun stop(): StopService.WithRawResponse = stop + + override fun stopIdsForAgency(): StopIdsForAgencyService.WithRawResponse = stopIdsForAgency + + override fun scheduleForStop(): ScheduleForStopService.WithRawResponse = scheduleForStop + + override fun route(): RouteService.WithRawResponse = route + + override fun routeIdsForAgency(): RouteIdsForAgencyService.WithRawResponse = + routeIdsForAgency + + override fun routesForLocation(): RoutesForLocationService.WithRawResponse = + routesForLocation + + override fun routesForAgency(): RoutesForAgencyService.WithRawResponse = routesForAgency + + override fun scheduleForRoute(): ScheduleForRouteService.WithRawResponse = scheduleForRoute + + override fun arrivalAndDeparture(): ArrivalAndDepartureService.WithRawResponse = + arrivalAndDeparture + + override fun trip(): TripService.WithRawResponse = trip + + override fun tripsForLocation(): TripsForLocationService.WithRawResponse = tripsForLocation + + override fun tripDetails(): TripDetailService.WithRawResponse = tripDetails + + override fun tripForVehicle(): TripForVehicleService.WithRawResponse = tripForVehicle + + override fun tripsForRoute(): TripsForRouteService.WithRawResponse = tripsForRoute + + override fun reportProblemWithStop(): ReportProblemWithStopService.WithRawResponse = + reportProblemWithStop + + override fun reportProblemWithTrip(): ReportProblemWithTripService.WithRawResponse = + reportProblemWithTrip + + override fun searchForStop(): SearchForStopService.WithRawResponse = searchForStop + + override fun searchForRoute(): SearchForRouteService.WithRawResponse = searchForRoute + + override fun block(): BlockService.WithRawResponse = block + + override fun shape(): ShapeService.WithRawResponse = shape + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt index 9602a26..e2902a3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt @@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.BeanProperty import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.JavaType import com.fasterxml.jackson.databind.JsonDeserializer -import com.fasterxml.jackson.databind.JsonMappingException import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer @@ -18,7 +17,7 @@ abstract class BaseDeserializer(type: KClass) : override fun createContextual( context: DeserializationContext, - property: BeanProperty? + property: BeanProperty?, ): JsonDeserializer { return this } @@ -29,31 +28,17 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: TypeReference, - validate: (T) -> Unit = {} - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: JavaType, - validate: (T) -> Unit = {} - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt 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 index 370b3f4..07ee264 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt @@ -3,71 +3,112 @@ package org.onebusaway.core import com.fasterxml.jackson.databind.json.JsonMapper -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.time.Clock +import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient import org.onebusaway.core.http.PhantomReachableClosingHttpClient +import org.onebusaway.core.http.QueryParams import org.onebusaway.core.http.RetryingHttpClient class ClientOptions private constructor( private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, + @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @get:JvmName("baseUrl") val baseUrl: String, - @get:JvmName("headers") val headers: ListMultimap, - @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, + @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, @get:JvmName("apiKey") val apiKey: String, ) { + init { + if (checkJacksonVersionCompatibility) { + checkJacksonVersionCompatibility() + } + } + fun toBuilder() = Builder().from(this) companion object { const val PRODUCTION_URL = "https://api.pugetsound.onebusaway.org" + /** + * Returns a mutable builder for constructing an instance of [ClientOptions]. + * + * The following fields are required: + * ```java + * .httpClient() + * .apiKey() + * ``` + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } - class Builder { + /** 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 clock: Clock = Clock.systemUTC() private var baseUrl: String = PRODUCTION_URL - private var headers: ListMultimap = ArrayListMultimap.create() - private var queryParams: ListMultimap = ArrayListMultimap.create() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false + private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 private var apiKey: String? = null @JvmSynthetic internal fun from(clientOptions: ClientOptions) = apply { httpClient = clientOptions.originalHttpClient + checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper clock = clientOptions.clock baseUrl = clientOptions.baseUrl - headers = ArrayListMultimap.create(clientOptions.headers) - queryParams = ArrayListMultimap.create(clientOptions.queryParams) + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries apiKey = clientOptions.apiKey } fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility + } + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } fun clock(clock: Clock) = apply { this.clock = clock } fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } + + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + fun headers(headers: Map>) = apply { this.headers.clear() putAllHeaders(headers) @@ -75,29 +116,34 @@ private constructor( fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - fun putHeaders(name: String, values: Iterable) = apply { - headers.putAll(name, values) - } + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } fun putAllHeaders(headers: Map>) = apply { - headers.forEach(::putHeaders) + this.headers.putAll(headers) } - fun replaceHeaders(name: String, value: String) = apply { - headers.replaceValues(name, listOf(value)) - } + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replaceValues(name, values) + headers.replace(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + fun replaceAllHeaders(headers: Map>) = apply { - headers.forEach(::replaceHeaders) + this.headers.replaceAll(headers) } - fun removeHeaders(name: String) = apply { headers.removeAll(name) } + fun removeHeaders(name: String) = apply { headers.remove(name) } - fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) } + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -107,45 +153,63 @@ private constructor( fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.putAll(key, values) + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) } fun putAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::putQueryParams) + this.queryParams.putAll(queryParams) } fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replaceValues(key, listOf(value)) + queryParams.replace(key, value) } fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replaceValues(key, values) + queryParams.replace(key, values) } - fun replaceAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::replaceQueryParams) + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) } - fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) } - - fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) } - - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) } - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun fromEnv() = apply { System.getenv("ONEBUSAWAY_API_KEY")?.let { apiKey(it) } } + fun baseUrl(): String = baseUrl + + fun fromEnv() = apply { + System.getenv("ONEBUSAWAY_SDK_BASE_URL")?.let { baseUrl(it) } + System.getenv("ONEBUSAWAY_API_KEY")?.let { apiKey(it) } + } + /** + * Returns an immutable instance of [ClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * .apiKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ClientOptions { - checkNotNull(httpClient) { "`httpClient` is required but was not set" } - checkNotNull(apiKey) { "`apiKey` is required but was not set" } + val httpClient = checkRequired("httpClient", httpClient) + val apiKey = checkRequired("apiKey", apiKey) - val headers = ArrayListMultimap.create() - val queryParams = ArrayListMultimap.create() + val headers = Headers.builder() + val queryParams = QueryParams.builder() headers.put("X-Stainless-Lang", "java") headers.put("X-Stainless-Arch", getOsArch()) headers.put("X-Stainless-OS", getOsName()) @@ -153,29 +217,33 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - if (!apiKey.isNullOrEmpty()) { - queryParams.put("key", apiKey) + apiKey.let { + if (!it.isEmpty()) { + queryParams.put("key", it) + } } - this.headers.asMap().forEach(headers::replaceValues) - this.queryParams.asMap().forEach(queryParams::replaceValues) + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) return ClientOptions( - httpClient!!, + httpClient, PhantomReachableClosingHttpClient( RetryingHttpClient.builder() - .httpClient(httpClient!!) + .httpClient(httpClient) .clock(clock) .maxRetries(maxRetries) .build() ), + checkJacksonVersionCompatibility, jsonMapper, clock, baseUrl, - headers.toImmutable(), - queryParams.toImmutable(), + headers.build(), + queryParams.build(), responseValidation, + timeout, maxRetries, - apiKey!!, + apiKey, ) } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/HttpRequestBodies.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/HttpRequestBodies.kt deleted file mode 100644 index 6794cf7..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/HttpRequestBodies.kt +++ /dev/null @@ -1,111 +0,0 @@ -@file:JvmName("HttpRequestBodies") - -package org.onebusaway.core - -import com.fasterxml.jackson.databind.json.JsonMapper -import java.io.ByteArrayOutputStream -import java.io.OutputStream -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder -import org.onebusaway.core.http.HttpRequestBody -import org.onebusaway.errors.OnebusawaySdkException - -@JvmSynthetic -internal inline fun json( - jsonMapper: JsonMapper, - value: T, -): HttpRequestBody { - return object : HttpRequestBody { - private var cachedBytes: ByteArray? = null - - private fun serialize(): ByteArray { - if (cachedBytes != null) return cachedBytes!! - - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, value) - cachedBytes = buffer.toByteArray() - return cachedBytes!! - } catch (e: Exception) { - throw OnebusawaySdkException("Error writing request", e) - } - } - - override fun writeTo(outputStream: OutputStream) { - outputStream.write(serialize()) - } - - override fun contentType(): String = "application/json" - - override fun contentLength(): Long { - return serialize().size.toLong() - } - - override fun repeatable(): Boolean = true - - override fun close() {} - } -} - -@JvmSynthetic -internal fun multipartFormData( - jsonMapper: JsonMapper, - parts: Array?> -): HttpRequestBody { - val builder = MultipartEntityBuilder.create() - parts.forEach { part -> - if (part?.value != null) { - when (part.value) { - is JsonValue -> { - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, part.value) - } catch (e: Exception) { - throw OnebusawaySdkException("Error serializing value to json", e) - } - builder.addBinaryBody( - part.name, - buffer.toByteArray(), - part.contentType, - part.filename - ) - } - is Boolean -> - builder.addTextBody( - part.name, - if (part.value) "true" else "false", - part.contentType - ) - is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is ByteArray -> - builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) - is String -> builder.addTextBody(part.name, part.value, part.contentType) - is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - else -> - throw IllegalArgumentException( - "Unsupported content type: ${part.value::class.java.simpleName}" - ) - } - } - } - val entity = builder.build() - - return object : HttpRequestBody { - override fun writeTo(outputStream: OutputStream) { - try { - return entity.writeTo(outputStream) - } catch (e: Exception) { - throw OnebusawaySdkException("Error writing request", e) - } - } - - override fun contentType(): String = entity.contentType - - override fun contentLength(): Long = -1 - - override fun repeatable(): Boolean = entity.isRepeatable - - override fun close() = entity.close() - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt index 7a4b2f8..d00e718 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt @@ -3,23 +3,165 @@ package org.onebusaway.core import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.MapperFeature import com.fasterxml.jackson.databind.SerializationFeature -import com.fasterxml.jackson.databind.cfg.CoercionAction.Fail -import com.fasterxml.jackson.databind.cfg.CoercionInputShape.Integer +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.cfg.CoercionAction +import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.type.LogicalType import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder +import com.fasterxml.jackson.module.kotlin.kotlinModule +import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField fun jsonMapper(): JsonMapper = - jacksonMapperBuilder() + JsonMapper.builder() + .addModule(kotlinModule()) .addModule(Jdk8Module()) .addModule(JavaTimeModule()) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) + .withCoercionConfig(LogicalType.Boolean) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Integer) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Float) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Textual) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Array) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Collection) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Map) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.POJO) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + } .serializationInclusion(JsonInclude.Include.NON_ABSENT) .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) - .withCoercionConfig(String::class.java) { it.setCoercion(Integer, Fail) } + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(MapperFeature.AUTO_DETECT_CREATORS) + .disable(MapperFeature.AUTO_DETECT_FIELDS) + .disable(MapperFeature.AUTO_DETECT_GETTERS) + .disable(MapperFeature.AUTO_DETECT_IS_GETTERS) + .disable(MapperFeature.AUTO_DETECT_SETTERS) .build() + +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer + + override fun serialize( + value: InputStream?, + gen: JsonGenerator?, + serializers: SerializerProvider?, + ) { + if (value == null) { + gen?.writeNull() + } else { + value.use { gen?.writeBinary(it.readBytes()) } + } + } +} + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/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 index e35ca9a..8391e58 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachable.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachable.kt @@ -15,10 +15,20 @@ internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable) check(observed !== closeable) { "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" } - closeWhenPhantomReachable?.let { it(observed, closeable::close) } + closeWhenPhantomReachable(observed, closeable::close) } -private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy { +/** + * Calls [close] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, close: () -> Unit) { + closeWhenPhantomReachable?.let { it(observed, close) } +} + +private val closeWhenPhantomReachable: ((Any, () -> Unit) -> Unit)? by lazy { try { val cleanerClass = Class.forName("java.lang.ref.Cleaner") val cleanerCreate = cleanerClass.getMethod("create") @@ -26,9 +36,9 @@ private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy { cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) val cleanerObject = cleanerCreate.invoke(null); - { observed, closeable -> + { observed, close -> try { - cleanerRegister.invoke(cleanerObject, observed, Runnable { closeable.close() }) + cleanerRegister.invoke(cleanerObject, observed, Runnable { close() }) } catch (e: ReflectiveOperationException) { if (e is InvocationTargetException) { when (val cause = e.cause) { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/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/RequestOptions.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/RequestOptions.kt index ec2f645..0967032 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/RequestOptions.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/RequestOptions.kt @@ -2,17 +2,7 @@ package org.onebusaway.core import java.time.Duration -class RequestOptions -private constructor( - val responseValidation: Boolean?, - val timeout: Duration?, -) { - fun applyDefaults(options: RequestOptions): RequestOptions { - return RequestOptions( - responseValidation = this.responseValidation ?: options.responseValidation, - timeout = this.timeout ?: options.timeout, - ) - } +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { companion object { @@ -20,21 +10,37 @@ private constructor( @JvmStatic fun none() = NONE + @JvmSynthetic + internal fun from(clientOptions: ClientOptions): RequestOptions = + builder() + .responseValidation(clientOptions.responseValidation) + .timeout(clientOptions.timeout) + .build() + @JvmStatic fun builder() = Builder() } - class Builder { + fun applyDefaults(options: RequestOptions): RequestOptions = + RequestOptions( + responseValidation = responseValidation ?: options.responseValidation, + timeout = + if (options.timeout != null && timeout != null) timeout.assign(options.timeout) + else timeout ?: options.timeout, + ) + + class Builder internal constructor() { + private var responseValidation: Boolean? = null - private var timeout: Duration? = null + private var timeout: Timeout? = null fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } - fun build(): RequestOptions { - return RequestOptions(responseValidation, timeout) - } + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun build(): RequestOptions = RequestOptions(responseValidation, timeout) } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt new file mode 100644 index 0000000..db8d478 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core + +import java.time.Duration +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class containing timeouts for various processing phases of a request. */ +class Timeout +private constructor( + private val connect: Duration?, + private val read: Duration?, + private val write: Duration?, + private val request: Duration?, +) { + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(): Duration = connect ?: Duration.ofMinutes(1) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(): Duration = read ?: request() + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(): Duration = write ?: request() + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(): Duration = request ?: Duration.ofMinutes(1) + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun default() = builder().build() + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var connect: Duration? = null + private var read: Duration? = null + private var write: Duration? = null + private var request: Duration? = null + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Duration?) = apply { this.connect = connect } + + /** Alias for calling [Builder.connect] with `connect.orElse(null)`. */ + fun connect(connect: Optional) = connect(connect.getOrNull()) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Duration?) = apply { this.read = read } + + /** Alias for calling [Builder.read] with `read.orElse(null)`. */ + fun read(read: Optional) = read(read.getOrNull()) + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Duration?) = apply { this.write = write } + + /** Alias for calling [Builder.write] with `write.orElse(null)`. */ + fun write(write: Optional) = write(write.getOrNull()) + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Duration?) = apply { this.request = request } + + /** Alias for calling [Builder.request] with `request.orElse(null)`. */ + fun request(request: Optional) = request(request.getOrNull()) + + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timeout = Timeout(connect, read, write, request) + } + + @JvmSynthetic + internal fun assign(target: Timeout): Timeout = + target + .toBuilder() + .apply { + connect?.let(this::connect) + read?.let(this::read) + write?.let(this::write) + request?.let(this::request) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ + + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt index 4ccb63c..f887344 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt @@ -2,8 +2,6 @@ package org.onebusaway.core -import com.google.common.collect.ImmutableListMultimap -import com.google.common.collect.ListMultimap import java.util.Collections import java.util.SortedMap import org.onebusaway.errors.OnebusawaySdkInvalidDataException @@ -18,15 +16,77 @@ internal fun List.toImmutable(): List = @JvmSynthetic internal fun Map.toImmutable(): Map = - if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap()) + if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) + +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() @JvmSynthetic internal fun , V> SortedMap.toImmutable(): SortedMap = 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 ListMultimap.toImmutable(): ListMultimap = - ImmutableListMultimap.copyOf(this) +internal fun Any?.contentToString(): String { + var string = arrayOf(this).contentDeepToString() + if (string.startsWith('[')) { + string = string.substring(1) + } + if (string.endsWith(']')) { + string = string.substring(0, string.length - 1) + } + return string +} internal interface Enum diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt index f5d6cde..a630d24 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt @@ -1,8 +1,6 @@ package org.onebusaway.core import com.fasterxml.jackson.annotation.JacksonAnnotationsInside -import com.fasterxml.jackson.annotation.JsonAutoDetect -import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator @@ -26,69 +24,146 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer -import java.nio.charset.Charset +import java.io.InputStream import java.util.Objects import java.util.Optional -import org.apache.hc.core5.http.ContentType import org.onebusaway.errors.OnebusawaySdkInvalidDataException +/** + * A class representing a serializable JSON field. + * + * It can either be a [KnownValue] value of type [T], matching the type the SDK expects, or an + * arbitrary JSON value that bypasses the type system (via [JsonValue]). + */ @JsonDeserialize(using = JsonField.Deserializer::class) sealed class JsonField { + /** + * Returns whether this field is missing, which means it will be omitted from the serialized + * JSON entirely. + */ fun isMissing(): Boolean = this is JsonMissing + /** Whether this field is explicitly set to `null`. */ fun isNull(): Boolean = this is JsonNull - fun asKnown(): Optional = - when (this) { - is KnownValue -> Optional.of(value) - else -> Optional.empty() - } + /** + * Returns an [Optional] containing this field's "known" value, meaning it matches the type the + * SDK expects, or an empty [Optional] if this field contains an arbitrary [JsonValue]. + * + * This is the opposite of [asUnknown]. + */ + fun asKnown(): + Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = Optional.ofNullable((this as? KnownValue)?.value) /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API - * then this method will return an empty `Optional`, otherwise the returned `Optional` is given - * a `JsonValue`. + * Returns an [Optional] containing this field's arbitrary [JsonValue], meaning it mismatches + * the type the SDK expects, or an empty [Optional] if this field contains a "known" value. + * + * This is the opposite of [asKnown]. */ - fun asUnknown(): Optional = - when (this) { - is JsonValue -> Optional.of(this) - else -> Optional.empty() - } + fun asUnknown(): Optional = Optional.ofNullable(this as? JsonValue) + /** + * Returns an [Optional] containing this field's boolean value, or an empty [Optional] if it + * doesn't contain a boolean. + * + * This method checks for both a [KnownValue] containing a boolean and for [JsonBoolean]. + */ fun asBoolean(): Optional = when (this) { is JsonBoolean -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Boolean) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's numerical value, or an empty [Optional] if it + * doesn't contain a number. + * + * This method checks for both a [KnownValue] containing a number and for [JsonNumber]. + */ fun asNumber(): Optional = when (this) { is JsonNumber -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Number) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's string value, or an empty [Optional] if it + * doesn't contain a string. + * + * This method checks for both a [KnownValue] containing a string and for [JsonString]. + */ fun asString(): Optional = when (this) { is JsonString -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? String) else -> Optional.empty() } fun asStringOrThrow(): String = - when (this) { - is JsonString -> value - else -> throw OnebusawaySdkInvalidDataException("Value is not a string") - } + asString().orElseThrow { OnebusawaySdkInvalidDataException("Value is not a string") } + /** + * Returns an [Optional] containing this field's list value, or an empty [Optional] if it + * doesn't contain a list. + * + * This method checks for both a [KnownValue] containing a list and for [JsonArray]. + */ fun asArray(): Optional> = when (this) { is JsonArray -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? List<*>)?.map { + try { + JsonValue.from(it) + } catch (e: IllegalArgumentException) { + // The known value is a list, but not all values are convertible to + // `JsonValue`. + return Optional.empty() + } + } + ) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's map value, or an empty [Optional] if it doesn't + * contain a map. + * + * This method checks for both a [KnownValue] containing a map and for [JsonObject]. + */ fun asObject(): Optional> = when (this) { is JsonObject -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? Map<*, *>) + ?.map { (key, value) -> + if (key !is String) { + return Optional.empty() + } + + val jsonValue = + try { + JsonValue.from(value) + } catch (e: IllegalArgumentException) { + // The known value is a map, but not all items are convertible + // to `JsonValue`. + return Optional.empty() + } + + key to jsonValue + } + ?.toMap() + ) else -> Optional.empty() } @@ -96,20 +171,24 @@ sealed class JsonField { internal fun getRequired(name: String): T = when (this) { is KnownValue -> value - is JsonMissing -> throw OnebusawaySdkInvalidDataException("'${name}' is not set") - is JsonNull -> throw OnebusawaySdkInvalidDataException("'${name}' is null") - else -> - throw OnebusawaySdkInvalidDataException("'${name}' is invalid, received ${this}") + is JsonMissing -> throw OnebusawaySdkInvalidDataException("`$name` is not set") + is JsonNull -> throw OnebusawaySdkInvalidDataException("`$name` is null") + else -> throw OnebusawaySdkInvalidDataException("`$name` is invalid, received $this") } @JvmSynthetic - internal fun getNullable(name: String): T? = + internal fun getOptional( + name: String + ): Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = when (this) { - is KnownValue -> value - is JsonMissing -> null - is JsonNull -> null - else -> - throw OnebusawaySdkInvalidDataException("'${name}' is invalid, received ${this}") + is KnownValue -> Optional.of(value) + is JsonMissing, + is JsonNull -> Optional.empty() + else -> throw OnebusawaySdkInvalidDataException("`$name` is invalid, received $this") } @JvmSynthetic @@ -119,19 +198,33 @@ sealed class JsonField { 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) { @@ -140,9 +233,13 @@ sealed class JsonField { } } - // This class is a Jackson filter that can be used to exclude missing properties from objects - // This filter should not be used directly and should instead use the @ExcludeMissing annotation + /** + * This class is a Jackson filter that can be used to exclude missing properties from objects. + * This filter should not be used directly and should instead use the @ExcludeMissing + * annotation. + */ class IsMissing { + override fun equals(other: Any?): Boolean = other is JsonMissing override fun hashCode(): Int = Objects.hash() @@ -154,21 +251,22 @@ sealed class JsonField { override fun createContextual( context: DeserializationContext, property: BeanProperty?, - ): JsonDeserializer> { - return Deserializer(context.contextualType?.containedType(0)) - } + ): JsonDeserializer> = Deserializer(context.contextualType?.containedType(0)) - override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> { - return type?.let { tryDeserialize(node, type) }?.let { of(it) } + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> = + type?.let { tryDeserialize(node, type) }?.let { of(it) } ?: JsonValue.fromJsonNode(node) - } - override fun getNullValue(context: DeserializationContext): JsonField<*> { - return JsonNull.of() - } + override fun getNullValue(context: DeserializationContext): JsonField<*> = JsonNull.of() } } +/** + * A class representing an arbitrary JSON value. + * + * It is immutable and assignable to any [JsonField], regardless of its expected type (i.e. its + * generic type argument). + */ @JsonDeserialize(using = JsonValue.Deserializer::class) sealed class JsonValue : JsonField() { @@ -176,6 +274,7 @@ sealed class JsonValue : JsonField() { fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + /** Returns the result of calling the [visitor] method corresponding to this value's variant. */ fun accept(visitor: Visitor): R = when (this) { is JsonMissing -> visitor.visitMissing() @@ -187,7 +286,12 @@ sealed class JsonValue : JsonField() { is JsonObject -> visitor.visitObject(values) } + /** + * An interface that defines how to map each variant state of a [JsonValue] to a value of type + * [R]. + */ interface Visitor { + fun visitNull(): R = visitDefault() fun visitMissing(): R = visitDefault() @@ -202,15 +306,52 @@ sealed class JsonValue : JsonField() { fun visitObject(values: Map): R = visitDefault() - fun visitDefault(): R { - throw RuntimeException("Unexpected value") - } + /** + * The default implementation for unimplemented visitor methods. + * + * @throws IllegalArgumentException in the default implementation. + */ + fun visitDefault(): R = throw IllegalArgumentException("Unexpected value") } companion object { private val JSON_MAPPER = jsonMapper() + /** + * Converts the given [value] to a [JsonValue]. + * + * This method works best on primitive types, [List] values, [Map] values, and nested + * combinations of these. For example: + * ```java + * // Create primitive JSON values + * JsonValue nullValue = JsonValue.from(null); + * JsonValue booleanValue = JsonValue.from(true); + * JsonValue numberValue = JsonValue.from(42); + * JsonValue stringValue = JsonValue.from("Hello World!"); + * + * // Create a JSON array value equivalent to `["Hello", "World"]` + * JsonValue arrayValue = JsonValue.from(List.of("Hello", "World")); + * + * // Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` + * JsonValue objectValue = JsonValue.from(Map.of( + * "a", 1, + * "b", 2 + * )); + * + * // Create an arbitrarily nested JSON equivalent to: + * // { + * // "a": [1, 2], + * // "b": [3, 4] + * // } + * JsonValue complexValue = JsonValue.from(Map.of( + * "a", List.of(1, 2), + * "b", List.of(3, 4) + * )); + * ``` + * + * @throws IllegalArgumentException if [value] is not JSON serializable. + */ @JvmStatic fun from(value: Any?): JsonValue = when (value) { @@ -219,6 +360,11 @@ sealed class JsonValue : JsonField() { else -> JSON_MAPPER.convertValue(value, JsonValue::class.java) } + /** + * Returns a [JsonValue] converted from the given Jackson [JsonNode]. + * + * @throws IllegalStateException for unsupported node types. + */ @JvmStatic fun fromJsonNode(node: JsonNode): JsonValue = when (node.nodeType) { @@ -240,16 +386,19 @@ sealed class JsonValue : JsonField() { } class Deserializer : BaseDeserializer(JsonValue::class) { - override fun ObjectCodec.deserialize(node: JsonNode): JsonValue { - return fromJsonNode(node) - } - override fun getNullValue(context: DeserializationContext?): JsonValue { - return JsonNull.of() - } + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue = fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext?): JsonValue = JsonNull.of() } } +/** + * A class representing a "known" JSON serializable value of type [T], matching the type the SDK + * expects. + * + * It is assignable to `JsonField`. + */ class KnownValue private constructor( @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T @@ -260,52 +409,67 @@ private constructor( return true } - return other is KnownValue<*> && value == other.value + return other is KnownValue<*> && value contentEquals other.value } - override fun hashCode() = value.hashCode() + override fun hashCode() = contentHash(value) - override fun toString() = value.toString() + override fun toString() = value.contentToString() companion object { + + /** Returns a [KnownValue] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) } } +/** + * A [JsonValue] representing an omitted JSON field. + * + * An instance of this class will cause a JSON field to be omitted from the serialized JSON + * entirely. + */ @JsonSerialize(using = JsonMissing.Serializer::class) class JsonMissing : JsonValue() { override fun toString() = "" companion object { + private val INSTANCE: JsonMissing = JsonMissing() + /** Returns the singleton instance of [JsonMissing]. */ @JvmStatic fun of() = INSTANCE } class Serializer : BaseSerializer(JsonMissing::class) { + override fun serialize( value: JsonMissing, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { - throw RuntimeException("JsonMissing cannot be serialized") + throw IllegalStateException("JsonMissing cannot be serialized") } } } +/** A [JsonValue] representing a JSON `null` value. */ @JsonSerialize(using = NullSerializer::class) class JsonNull : JsonValue() { override fun toString() = "null" companion object { + private val INSTANCE: JsonNull = JsonNull() + /** Returns the singleton instance of [JsonMissing]. */ @JsonCreator @JvmStatic fun of() = INSTANCE } } +/** A [JsonValue] representing a JSON boolean value. */ class JsonBoolean private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Boolean @@ -324,14 +488,18 @@ private constructor( override fun toString() = value.toString() companion object { + + /** Returns a [JsonBoolean] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: Boolean) = JsonBoolean(value) } } +/** A [JsonValue] representing a JSON number value. */ class JsonNumber private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Number ) : JsonValue() { + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -345,10 +513,13 @@ private constructor( override fun toString() = value.toString() companion object { + + /** Returns a [JsonNumber] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: Number) = JsonNumber(value) } } +/** A [JsonValue] representing a JSON string value. */ class JsonString private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: String @@ -367,10 +538,13 @@ private constructor( override fun toString() = value companion object { + + /** Returns a [JsonString] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: String) = JsonString(value) } } +/** A [JsonValue] representing a JSON array value. */ class JsonArray private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @@ -391,10 +565,13 @@ private constructor( override fun toString() = values.toString() companion object { + + /** Returns a [JsonArray] containing the given [values]. */ @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) } } +/** A [JsonValue] representing a JSON object value. */ class JsonObject private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @@ -415,124 +592,132 @@ private constructor( override fun toString() = values.toString() companion object { + + /** Returns a [JsonObject] containing the given [values]. */ @JsonCreator @JvmStatic fun of(values: Map) = JsonObject(values.toImmutable()) } } +/** A Jackson annotation for excluding fields set to [JsonMissing] from the serialized JSON. */ @JacksonAnnotationsInside -@JsonInclude( - JsonInclude.Include.CUSTOM, - valueFilter = JsonField.IsMissing::class, -) +@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) annotation class ExcludeMissing -@JacksonAnnotationsInside -@JsonAutoDetect( - getterVisibility = Visibility.NONE, - isGetterVisibility = Visibility.NONE, - setterVisibility = Visibility.NONE, - creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE -) -annotation class NoAutoDetect - -class MultipartFormValue -internal constructor( - val name: String, - val value: T, - val contentType: ContentType, - val filename: String? = null +/** A class representing a field in a `multipart/form-data` request. */ +class MultipartField +private constructor( + /** A [JsonField] value, which will be serialized to zero or more parts. */ + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: JsonField, + /** A content type for the serialized parts. */ + @get:JvmName("contentType") val contentType: String, + private val filename: String?, ) { - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - contentType, - filename, - when (value) { - is ByteArray -> value.contentHashCode() - is String -> value - is Boolean -> value - is Long -> value - is Double -> value - else -> value?.hashCode() - } - ) - } - return hashCode - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || this.javaClass != other.javaClass) return false + companion object { - other as MultipartFormValue<*> + /** + * Returns a [MultipartField] containing the given [value] as a [KnownValue]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: T?) = builder().value(value).build() + + /** + * Returns a [MultipartField] containing the given [value]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: JsonField) = builder().value(value).build() + + /** + * Returns a mutable builder for constructing an instance of [MultipartField]. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun builder() = Builder() + } - if (name != other.name || contentType != other.contentType || filename != other.filename) - return false + /** Returns the filename directive that will be included in the serialized field. */ + fun filename(): Optional = Optional.ofNullable(filename) - return when { - value is ByteArray && other.value is ByteArray -> value contentEquals other.value - else -> value?.equals(other.value) ?: (other.value == null) + @JvmSynthetic + internal fun map(transform: (T) -> R): MultipartField = + builder().value(value.map(transform)).contentType(contentType).filename(filename).build() + + /** A builder for [MultipartField]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var contentType: String? = null + private var filename: String? = null + + fun value(value: JsonField) = apply { this.value = value } + + fun value(value: T?) = value(JsonField.ofNullable(value)) + + fun contentType(contentType: String) = apply { this.contentType = contentType } + + fun filename(filename: String?) = apply { this.filename = filename } + + /** Alias for calling [Builder.filename] with `filename.orElse(null)`. */ + fun filename(filename: Optional) = filename(filename.orElse(null)) + + /** + * Returns an immutable instance of [MultipartField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MultipartField { + val value = checkRequired("value", value) + return MultipartField( + value, + contentType + ?: if ( + value is KnownValue && + (value.value is InputStream || value.value is ByteArray) + ) + "application/octet-stream" + else "text/plain; charset=utf-8", + filename, + ) } } - override fun toString(): String = - "MultipartFormValue{name=$name, contentType=$contentType, filename=$filename, value=${valueToString()}}" + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } + + override fun hashCode(): Int = hashCode - private fun valueToString(): String = - when (value) { - is ByteArray -> "ByteArray of size ${value.size}" - else -> value.toString() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - companion object { - internal fun fromString( - name: String, - value: String, - contentType: ContentType - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromBoolean( - name: String, - value: Boolean, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromLong( - name: String, - value: Long, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromDouble( - name: String, - value: Double, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromEnum( - name: String, - value: T, - contentType: ContentType - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromByteArray( - name: String, - value: ByteArray, - contentType: ContentType, - filename: String? = null - ): MultipartFormValue = MultipartFormValue(name, value, contentType, filename) + return other is MultipartField<*> && + value == other.value && + contentType == other.contentType && + filename == other.filename } -} -internal object ContentTypes { - val DefaultText = ContentType.create(ContentType.TEXT_PLAIN.mimeType, Charset.forName("UTF-8")) - val DefaultBinary = ContentType.DEFAULT_BINARY + override fun toString(): String = + "MultipartField{value=$value, contentType=$contentType, filename=$filename}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt index f7938ba..2d6cd63 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt @@ -1,17 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + @file:JvmName("ErrorHandler") package org.onebusaway.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper -import com.google.common.collect.ListMultimap -import java.io.ByteArrayInputStream -import java.io.InputStream +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue import org.onebusaway.core.http.HttpResponse import org.onebusaway.core.http.HttpResponse.Handler import org.onebusaway.errors.BadRequestException import org.onebusaway.errors.InternalServerException import org.onebusaway.errors.NotFoundException -import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.errors.PermissionDeniedException import org.onebusaway.errors.RateLimitException import org.onebusaway.errors.UnauthorizedException @@ -19,109 +19,66 @@ import org.onebusaway.errors.UnexpectedStatusCodeException import org.onebusaway.errors.UnprocessableEntityException @JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { - val handler = jsonHandler(jsonMapper) +internal fun errorHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) - return object : Handler { - override fun handle(response: HttpResponse): OnebusawaySdkError = + return object : Handler { + override fun handle(response: HttpResponse): JsonValue = try { handler.handle(response) } catch (e: Exception) { - OnebusawaySdkError.builder().build() + JsonMissing.of() } } } @JvmSynthetic -internal fun Handler.withErrorHandler( - errorHandler: Handler -): Handler = +internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = object : Handler { - override fun handle(response: HttpResponse): T { + override fun handle(response: HttpResponse): T = when (val statusCode = response.statusCode()) { - in 200..299 -> { - return this@withErrorHandler.handle(response) - } - 400 -> { - val buffered = response.buffered() - throw BadRequestException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 401 -> { - val buffered = response.buffered() - throw UnauthorizedException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 403 -> { - val buffered = response.buffered() - throw PermissionDeniedException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 404 -> { - val buffered = response.buffered() - throw NotFoundException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 422 -> { - val buffered = response.buffered() - throw UnprocessableEntityException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 429 -> { - val buffered = response.buffered() - throw RateLimitException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - in 500..599 -> { - val buffered = response.buffered() - throw InternalServerException( - statusCode, - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - else -> { - val buffered = response.buffered() - throw UnexpectedStatusCodeException( - statusCode, - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } + in 200..299 -> this@withErrorHandler.handle(response) + 400 -> + throw BadRequestException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 401 -> + throw UnauthorizedException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 403 -> + throw PermissionDeniedException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 404 -> + throw NotFoundException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 422 -> + throw UnprocessableEntityException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 429 -> + throw RateLimitException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + in 500..599 -> + throw InternalServerException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + else -> + throw UnexpectedStatusCodeException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() } - } - } - -private fun HttpResponse.buffered(): HttpResponse { - val body = body().readBytes() - - return object : HttpResponse { - override fun statusCode(): Int = this@buffered.statusCode() - - override fun headers(): ListMultimap = this@buffered.headers() - - override fun body(): InputStream = ByteArrayInputStream(body) - - override fun close() = this@buffered.close() } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt index 6ae84af..18b8ac9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt @@ -6,16 +6,15 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.onebusaway.core.http.HttpResponse import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkException +import org.onebusaway.errors.OnebusawaySdkInvalidDataException @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = object : Handler { - override fun handle(response: HttpResponse): T { + override fun handle(response: HttpResponse): T = try { - return jsonMapper.readValue(response.body(), jacksonTypeRef()) + jsonMapper.readValue(response.body(), jacksonTypeRef()) } catch (e: Exception) { - throw OnebusawaySdkException("Error reading response", e) + throw OnebusawaySdkInvalidDataException("Error reading response", e) } - } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/AsyncStreamResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/AsyncStreamResponse.kt new file mode 100644 index 0000000..2f97f46 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/AsyncStreamResponse.kt @@ -0,0 +1,157 @@ +package org.onebusaway.core.http + +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference +import org.onebusaway.core.http.AsyncStreamResponse.Handler + +/** + * A class providing access to an API response as an asynchronous stream of chunks of type [T], + * where each chunk can be individually processed as soon as it arrives instead of waiting on the + * full response. + */ +interface AsyncStreamResponse { + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the client's configured or default thread pool. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler): AsyncStreamResponse + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the given [executor]. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse + + /** + * Returns a future that completes when a stream is fully consumed, errors, or gets closed + * early. + */ + fun onCompleteFuture(): CompletableFuture + + /** + * Closes this resource, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because this response should not be + * synchronously closed via try-with-resources. + */ + fun close() + + /** A class for handling streaming events. */ + fun interface Handler { + + /** Called whenever a chunk is received. */ + fun onNext(value: T) + + /** + * Called when a stream is fully consumed, errors, or gets closed early. + * + * [onNext] will not be called once this method is called. + * + * @param error Non-empty if the stream completed due to an error. + */ + fun onComplete(error: Optional) {} + } +} + +@JvmSynthetic +internal fun CompletableFuture>.toAsync(streamHandlerExecutor: Executor) = + PhantomReachableClosingAsyncStreamResponse( + object : AsyncStreamResponse { + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + init { + this@toAsync.whenComplete { _, error -> + // If an error occurs from the original future, then we should resolve the + // `onCompleteFuture` even if `subscribe` has not been called. + error?.let(onCompleteFuture::completeExceptionally) + } + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = + subscribe(handler, streamHandlerExecutor) + + override fun subscribe( + handler: Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + this@toAsync.whenCompleteAsync( + { streamResponse, futureError -> + if (state.get() == State.CLOSED) { + // Avoid doing any work if `close` was called before the future + // completed. + return@whenCompleteAsync + } + + if (futureError != null) { + // An error occurred before we started passing chunks to the handler. + handler.onComplete(Optional.of(futureError)) + return@whenCompleteAsync + } + + var streamError: Throwable? = null + try { + streamResponse.stream().forEach(handler::onNext) + } catch (e: Throwable) { + streamError = e + } + + try { + handler.onComplete(Optional.ofNullable(streamError)) + } finally { + try { + // Notify completion via the `onCompleteFuture` as well. This is in + // a separate `try-finally` block so that we still complete the + // future if `handler.onComplete` throws. + if (streamError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(streamError) + } + } finally { + close() + } + } + }, + executor, + ) + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + this@toAsync.whenComplete { streamResponse, error -> streamResponse?.close() } + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } + } + ) + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt index 1e17303..c3820c3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt @@ -6,7 +6,7 @@ import org.onebusaway.core.toImmutable class Headers private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() @@ -22,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = TreeMap(String.CASE_INSENSITIVE_ORDER) @@ -74,7 +74,7 @@ private constructor( values.toImmutable() } .toImmutable(), - size + size, ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt index bb0f294..aa57cf6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt @@ -1,5 +1,3 @@ -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.core.http import java.lang.AutoCloseable @@ -8,15 +6,21 @@ import org.onebusaway.core.RequestOptions interface HttpClient : AutoCloseable { - @JvmOverloads fun execute( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - @JvmOverloads + fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + fun executeAsync( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + fun executeAsync(request: HttpRequest): CompletableFuture = + executeAsync(request, RequestOptions.none()) + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt index 9139930..1b4396b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt @@ -1,8 +1,6 @@ package org.onebusaway.core.http -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import com.google.common.collect.MultimapBuilder +import org.onebusaway.core.checkRequired import org.onebusaway.core.toImmutable class HttpRequest @@ -10,11 +8,13 @@ private constructor( @get:JvmName("method") val method: HttpMethod, @get:JvmName("url") val url: String?, @get:JvmName("pathSegments") val pathSegments: List, - @get:JvmName("headers") val headers: ListMultimap, - @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("body") val body: HttpRequestBody?, ) { + fun toBuilder(): Builder = Builder().from(this) + override fun toString(): String = "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" @@ -22,16 +22,25 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var method: HttpMethod? = null private var url: String? = null private var pathSegments: MutableList = mutableListOf() - private var headers: ListMultimap = - MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).arrayListValues().build() - private var queryParams: ListMultimap = ArrayListMultimap.create() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() private var body: HttpRequestBody? = null + @JvmSynthetic + internal fun from(request: HttpRequest) = apply { + method = request.method + url = request.url + pathSegments = request.pathSegments.toMutableList() + headers = request.headers.toBuilder() + queryParams = request.queryParams.toBuilder() + body = request.body + } + fun method(method: HttpMethod) = apply { this.method = method } fun url(url: String) = apply { this.url = url } @@ -42,6 +51,11 @@ private constructor( this.pathSegments.addAll(pathSegments) } + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + fun headers(headers: Map>) = apply { this.headers.clear() putAllHeaders(headers) @@ -49,29 +63,34 @@ private constructor( fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - fun putHeaders(name: String, values: Iterable) = apply { - headers.putAll(name, values) - } + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } fun putAllHeaders(headers: Map>) = apply { - headers.forEach(::putHeaders) + this.headers.putAll(headers) } - fun replaceHeaders(name: String, value: String) = apply { - headers.replaceValues(name, listOf(value)) - } + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replaceValues(name, values) + headers.replace(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + fun replaceAllHeaders(headers: Map>) = apply { - headers.forEach(::replaceHeaders) + this.headers.replaceAll(headers) } - fun removeHeaders(name: String) = apply { headers.removeAll(name) } + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } - fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) } + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -81,38 +100,46 @@ private constructor( fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.putAll(key, values) + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) } fun putAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::putQueryParams) + this.queryParams.putAll(queryParams) } fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replaceValues(key, listOf(value)) + queryParams.replace(key, value) } fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replaceValues(key, values) + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) } fun replaceAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::replaceQueryParams) + this.queryParams.replaceAll(queryParams) } - fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) } + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) } + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } fun body(body: HttpRequestBody) = apply { this.body = body } fun build(): HttpRequest = HttpRequest( - checkNotNull(method) { "`method` is required but was not set" }, + checkRequired("method", method), url, pathSegments.toImmutable(), - headers, - queryParams.toImmutable(), + headers.build(), + queryParams.build(), body, ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBodies.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBodies.kt new file mode 100644 index 0000000..0822ec1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBodies.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("HttpRequestBodies") + +package org.onebusaway.core.http + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.node.JsonNodeType +import java.io.InputStream +import java.io.OutputStream +import kotlin.jvm.optionals.getOrNull +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.apache.hc.core5.http.ContentType +import org.apache.hc.core5.http.HttpEntity +import org.onebusaway.core.MultipartField +import org.onebusaway.errors.OnebusawaySdkInvalidDataException + +@JvmSynthetic +internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = + object : HttpRequestBody { + private val bytes: ByteArray by lazy { jsonMapper.writeValueAsBytes(value) } + + override fun writeTo(outputStream: OutputStream) = outputStream.write(bytes) + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long = bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + fields: Map>, +): HttpRequestBody = + object : HttpRequestBody { + private val entity: HttpEntity by lazy { + MultipartEntityBuilder.create() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + addBinaryBody( + name, + bytes, + ContentType.parseLenient(field.contentType), + field.filename().getOrNull(), + ) + } + } + } + .build() + } + + private fun serializePart( + name: String, + node: JsonNode, + ): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) + JsonNodeType.BOOLEAN -> + sequenceOf(name to node.booleanValue().toString().inputStream()) + JsonNodeType.NUMBER -> + sequenceOf(name to node.numberValue().toString().inputStream()) + JsonNodeType.ARRAY -> + node.elements().asSequence().flatMap { element -> serializePart(name, element) } + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> + throw OnebusawaySdkInvalidDataException( + "Unexpected JsonNode type: ${node.nodeType}" + ) + } + + private fun String.inputStream(): InputStream = toByteArray().inputStream() + + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = entity.contentLength + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt index b9617f4..4086d94 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt @@ -1,12 +1,11 @@ package org.onebusaway.core.http -import java.io.IOException import java.io.OutputStream import java.lang.AutoCloseable interface HttpRequestBody : AutoCloseable { - @Throws(IOException::class) fun writeTo(outputStream: OutputStream) + fun writeTo(outputStream: OutputStream) fun contentType(): String? @@ -21,5 +20,6 @@ interface HttpRequestBody : AutoCloseable { */ fun repeatable(): Boolean + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ override fun close() } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt index b2870ca..275cbd4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt @@ -1,17 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.core.http -import com.google.common.collect.ListMultimap import java.io.InputStream -import java.lang.AutoCloseable interface HttpResponse : AutoCloseable { fun statusCode(): Int - fun headers(): ListMultimap + 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 index f923a21..cec4a4b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt @@ -4,6 +4,11 @@ import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions import org.onebusaway.core.closeWhenPhantomReachable +/** + * A delegating wrapper around an `HttpClient` that closes it once it's only phantom reachable. + * + * This class ensures the `HttpClient` is closed even if the user forgets to close it. + */ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { init { closeWhenPhantomReachable(this, httpClient) @@ -14,7 +19,7 @@ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpCli override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture = httpClient.executeAsync(request, requestOptions) override fun close() = httpClient.close() diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingStreamResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingStreamResponse.kt new file mode 100644 index 0000000..2a7c4f1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingStreamResponse.kt @@ -0,0 +1,21 @@ +package org.onebusaway.core.http + +import java.util.stream.Stream +import org.onebusaway.core.closeWhenPhantomReachable + +/** + * A delegating wrapper around a `StreamResponse` that closes it once it's only phantom reachable. + * + * This class ensures the `StreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingStreamResponse( + private val streamResponse: StreamResponse +) : StreamResponse { + init { + closeWhenPhantomReachable(this, streamResponse) + } + + override fun stream(): Stream = streamResponse.stream() + + override fun close() = streamResponse.close() +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt index a5e7ddf..e88dc5d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.core.http import org.onebusaway.core.toImmutable @@ -5,7 +7,7 @@ import org.onebusaway.core.toImmutable class QueryParams private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() @@ -21,7 +23,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = mutableMapOf() private var size: Int = 0 diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt index 37bc637..5aec683 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt @@ -17,54 +17,56 @@ import java.util.function.Function import kotlin.math.min import kotlin.math.pow import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.errors.OnebusawaySdkIoException class RetryingHttpClient private constructor( private val httpClient: HttpClient, + private val sleeper: Sleeper, private val clock: Clock, private val maxRetries: Int, private val idempotencyHeader: String?, ) : HttpClient { - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) } - maybeAddIdempotencyHeader(request) + var modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. - val shouldSendRetryCount = !request.headers.containsKey("x-stainless-retry-count") + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") var retries = 0 while (true) { if (shouldSendRetryCount) { - setRetryCountHeader(request, retries) + modifiedRequest = setRetryCountHeader(modifiedRequest, retries) } val response = try { - val response = httpClient.execute(request, requestOptions) + val response = httpClient.execute(modifiedRequest, requestOptions) if (++retries > maxRetries || !shouldRetry(response)) { return response } response - } catch (t: Throwable) { - if (++retries > maxRetries || !shouldRetry(t)) { - throw t + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable } null } - val backoffMillis = getRetryBackoffMillis(retries, response) - Thread.sleep(backoffMillis.toMillis()) + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + sleeper.sleep(backoffDuration) } } @@ -76,10 +78,11 @@ private constructor( return httpClient.executeAsync(request, requestOptions) } - maybeAddIdempotencyHeader(request) + val modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. - val shouldSendRetryCount = !request.headers.containsKey("x-stainless-retry-count") + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") var retries = 0 @@ -87,16 +90,15 @@ private constructor( request: HttpRequest, requestOptions: RequestOptions, ): CompletableFuture { - if (shouldSendRetryCount) { - setRetryCountHeader(request, retries) - } + val requestWithRetryCount = + if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request return httpClient - .executeAsync(request, requestOptions) + .executeAsync(requestWithRetryCount, requestOptions) .handleAsync( fun( response: HttpResponse?, - throwable: Throwable? + throwable: Throwable?, ): CompletableFuture { if (response != null) { if (++retries > maxRetries || !shouldRetry(response)) { @@ -110,11 +112,13 @@ private constructor( } } - val backoffMillis = getRetryBackoffMillis(retries, response) - return sleepAsync(backoffMillis.toMillis()).thenCompose { - executeWithRetries(request, requestOptions) + 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() @@ -122,7 +126,7 @@ private constructor( .thenCompose(Function.identity()) } - return executeWithRetries(request, requestOptions) + return executeWithRetries(modifiedRequest, requestOptions) } override fun close() = httpClient.close() @@ -132,23 +136,26 @@ private constructor( // the body data aren't available on subsequent attempts. request.body?.repeatable() ?: true - private fun setRetryCountHeader(request: HttpRequest, retries: Int) { - request.headers.removeAll("x-stainless-retry-count") - request.headers.put("x-stainless-retry-count", retries.toString()) - } + private fun setRetryCountHeader(request: HttpRequest, retries: Int): HttpRequest = + request.toBuilder().replaceHeaders("X-Stainless-Retry-Count", retries.toString()).build() private fun idempotencyKey(): String = "stainless-java-retry-${UUID.randomUUID()}" - private fun maybeAddIdempotencyHeader(request: HttpRequest) { - if (idempotencyHeader != null && !request.headers.containsKey(idempotencyHeader)) { - // Set a header to uniquely identify the request when retried - request.headers.put(idempotencyHeader, idempotencyKey()) + private fun maybeAddIdempotencyHeader(request: HttpRequest): HttpRequest { + if (idempotencyHeader == null || request.headers.names().contains(idempotencyHeader)) { + return request } + + return request + .toBuilder() + // Set a header to uniquely identify the request when retried. + .putHeader(idempotencyHeader, idempotencyKey()) + .build() } private fun shouldRetry(response: HttpResponse): Boolean { // Note: this is not a standard header - val shouldRetryHeader = response.headers().get("x-should-retry").getOrNull(0) + val shouldRetryHeader = response.headers().values("X-Should-Retry").getOrNull(0) val statusCode = response.statusCode() return when { @@ -174,26 +181,26 @@ private constructor( // retried. throwable is IOException || throwable is OnebusawaySdkIoException - private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { + private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After response ?.headers() ?.let { headers -> headers - .get("Retry-After-Ms") + .values("Retry-After-Ms") .getOrNull(0) ?.toFloatOrNull() ?.times(TimeUnit.MILLISECONDS.toNanos(1)) - ?: headers.get("Retry-After").getOrNull(0)?.let { retryAfter -> + ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { ChronoUnit.MILLIS.between( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, - DateTimeFormatter.RFC_1123_DATE_TIME - ) + DateTimeFormatter.RFC_1123_DATE_TIME, + ), ) } catch (e: DateTimeParseException) { null @@ -219,35 +226,42 @@ private constructor( return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) } - private fun sleepAsync(millis: Long): CompletableFuture { - val future = CompletableFuture() - TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis - ) - return future - } - companion object { - private val TIMER = Timer("RetryingHttpClient", true) - @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var httpClient: HttpClient? = null + private var sleeper: Sleeper = + object : Sleeper { + + private val timer = Timer("RetryingHttpClient", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + } private var clock: Clock = Clock.systemUTC() private var maxRetries: Int = 2 private var idempotencyHeader: String? = null fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + @JvmSynthetic internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + fun clock(clock: Clock) = apply { this.clock = clock } fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } @@ -256,10 +270,18 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( - checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + checkRequired("httpClient", httpClient), + sleeper, clock, maxRetries, idempotencyHeader, ) } + + internal interface Sleeper { + + fun sleep(duration: Duration) + + fun sleepAsync(duration: Duration): CompletableFuture + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/StreamResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/StreamResponse.kt new file mode 100644 index 0000000..08470f9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/StreamResponse.kt @@ -0,0 +1,19 @@ +package org.onebusaway.core.http + +import java.util.stream.Stream + +interface StreamResponse : AutoCloseable { + + fun stream(): Stream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} + +@JvmSynthetic +internal fun StreamResponse.map(transform: (T) -> R): StreamResponse = + object : StreamResponse { + override fun stream(): Stream = this@map.stream().map(transform) + + override fun close() = this@map.close() + } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt index dee8196..2ed561f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +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()) -class BadRequestException( - headers: ListMultimap, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(400, headers, body, error) + /** + * Returns an immutable instance of [BadRequestException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BadRequestException = + BadRequestException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt index 5c3229f..feb6ec9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt @@ -1,10 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +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()) -class InternalServerException( - statusCode: Int, - headers: ListMultimap, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(statusCode, headers, body, error) + /** + * Returns an immutable instance of [InternalServerException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalServerException = + InternalServerException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt index 35e69c4..d6aef12 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt @@ -1,9 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +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()) -class NotFoundException( - headers: ListMultimap, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(404, headers, body, error) + /** + * Returns an immutable instance of [NotFoundException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotFoundException = + NotFoundException(checkRequired("headers", headers), checkRequired("body", body), cause) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt deleted file mode 100644 index 6f0a191..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.errors - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = OnebusawaySdkError.Builder::class) -@NoAutoDetect -class OnebusawaySdkError -constructor( - private val additionalProperties: Map, -) { - - @JsonAnyGetter fun additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OnebusawaySdkError && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - - override fun toString() = "OnebusawaySdkError{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - fun from(error: OnebusawaySdkError) = apply { - additionalProperties(error.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): OnebusawaySdkError = OnebusawaySdkError(additionalProperties.toImmutable()) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt index 96d7d2d..9e14f04 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt @@ -1,23 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.JsonValue +import org.onebusaway.core.http.Headers abstract class OnebusawaySdkServiceException -@JvmOverloads -constructor( - private val statusCode: Int, - private val headers: ListMultimap, - private val body: String, - private val error: OnebusawaySdkError, - message: String = "$statusCode: $error", - cause: Throwable? = null -) : OnebusawaySdkException(message, cause) { - - fun statusCode(): Int = statusCode +protected constructor(message: String, cause: Throwable? = null) : + OnebusawaySdkException(message, cause) { - fun headers(): ListMultimap = headers + abstract fun statusCode(): Int - fun body(): String = body + abstract fun headers(): Headers - fun error(): OnebusawaySdkError = error + abstract fun body(): JsonValue } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt index bb06e6a..28a3b5a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +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()) -class PermissionDeniedException( - headers: ListMultimap, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(403, headers, body, error) + /** + * Returns an immutable instance of [PermissionDeniedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PermissionDeniedException = + PermissionDeniedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt index c210a32..8e68c49 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +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()) -class RateLimitException( - headers: ListMultimap, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(429, headers, body, error) + /** + * Returns an immutable instance of [RateLimitException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RateLimitException = + RateLimitException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt index dc34495..79e2116 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +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()) -class UnauthorizedException( - headers: ListMultimap, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(401, headers, body, error) + /** + * Returns an immutable instance of [UnauthorizedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnauthorizedException = + UnauthorizedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt index a54c02d..f4aaa51 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt @@ -1,10 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +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()) -class UnexpectedStatusCodeException( - statusCode: Int, - headers: ListMultimap, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(statusCode, headers, body, error) + /** + * Returns an immutable instance of [UnexpectedStatusCodeException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnexpectedStatusCodeException = + UnexpectedStatusCodeException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt index a30211a..be66612 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors -import com.google.common.collect.ListMultimap +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()) -class UnprocessableEntityException( - headers: ListMultimap, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(422, headers, body, error) + /** + * 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/AgenciesWithCoverageListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt deleted file mode 100644 index 6e8ed63..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt +++ /dev/null @@ -1,146 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class AgenciesWithCoverageListParams -constructor( - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AgenciesWithCoverageListParams && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "AgenciesWithCoverageListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(agenciesWithCoverageListParams: AgenciesWithCoverageListParams) = apply { - additionalHeaders(agenciesWithCoverageListParams.additionalHeaders) - additionalQueryParams(agenciesWithCoverageListParams.additionalQueryParams) - } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): AgenciesWithCoverageListParams = - AgenciesWithCoverageListParams( - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable() - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt deleted file mode 100644 index 0349ee9..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt +++ /dev/null @@ -1,452 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = AgenciesWithCoverageListResponse.Builder::class) -@NoAutoDetect -class AgenciesWithCoverageListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): AgenciesWithCoverageListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(agenciesWithCoverageListResponse: AgenciesWithCoverageListResponse) = - apply { - this.code = agenciesWithCoverageListResponse.code - this.currentTime = agenciesWithCoverageListResponse.currentTime - this.text = agenciesWithCoverageListResponse.text - this.version = agenciesWithCoverageListResponse.version - this.data = agenciesWithCoverageListResponse.data - additionalProperties(agenciesWithCoverageListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): AgenciesWithCoverageListResponse = - AgenciesWithCoverageListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val agencyId: JsonField, - private val lat: JsonField, - private val latSpan: JsonField, - private val lon: JsonField, - private val lonSpan: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun lat(): Double = lat.getRequired("lat") - - fun latSpan(): Double = latSpan.getRequired("latSpan") - - fun lon(): Double = lon.getRequired("lon") - - fun lonSpan(): Double = lonSpan.getRequired("lonSpan") - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId - - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - @JsonProperty("latSpan") @ExcludeMissing fun _latSpan() = latSpan - - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonProperty("lonSpan") @ExcludeMissing fun _lonSpan() = lonSpan - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - agencyId() - lat() - latSpan() - lon() - lonSpan() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var agencyId: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var latSpan: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var lonSpan: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.agencyId = list.agencyId - this.lat = list.lat - this.latSpan = list.latSpan - this.lon = list.lon - this.lonSpan = list.lonSpan - additionalProperties(list.additionalProperties) - } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - @JsonProperty("agencyId") - @ExcludeMissing - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun latSpan(latSpan: Double) = latSpan(JsonField.of(latSpan)) - - @JsonProperty("latSpan") - @ExcludeMissing - fun latSpan(latSpan: JsonField) = apply { this.latSpan = latSpan } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun lonSpan(lonSpan: Double) = lonSpan(JsonField.of(lonSpan)) - - @JsonProperty("lonSpan") - @ExcludeMissing - fun lonSpan(lonSpan: JsonField) = apply { this.lonSpan = lonSpan } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - agencyId, - lat, - latSpan, - lon, - lonSpan, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.agencyId == other.agencyId && this.lat == other.lat && this.latSpan == other.latSpan && this.lon == other.lon && this.lonSpan == other.lonSpan && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, lat, latSpan, lon, lonSpan, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{agencyId=$agencyId, lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AgenciesWithCoverageListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "AgenciesWithCoverageListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt deleted file mode 100644 index 69a140e..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class AgencyRetrieveParams -constructor( - private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun agencyId(): String = agencyId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AgencyRetrieveParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "AgencyRetrieveParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(agencyRetrieveParams: AgencyRetrieveParams) = apply { - this.agencyId = agencyRetrieveParams.agencyId - additionalHeaders(agencyRetrieveParams.additionalHeaders) - additionalQueryParams(agencyRetrieveParams.additionalQueryParams) - } - - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): AgencyRetrieveParams = - AgencyRetrieveParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt deleted file mode 100644 index 3dbad5f..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt +++ /dev/null @@ -1,534 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = AgencyRetrieveResponse.Builder::class) -@NoAutoDetect -class AgencyRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): AgencyRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(agencyRetrieveResponse: AgencyRetrieveResponse) = apply { - this.code = agencyRetrieveResponse.code - this.currentTime = agencyRetrieveResponse.currentTime - this.text = agencyRetrieveResponse.text - this.version = agencyRetrieveResponse.version - this.data = agencyRetrieveResponse.data - additionalProperties(agencyRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): AgencyRetrieveResponse = - AgencyRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val disclaimer: JsonField, - private val email: JsonField, - private val fareUrl: JsonField, - private val id: JsonField, - private val lang: JsonField, - private val name: JsonField, - private val phone: JsonField, - private val privateService: JsonField, - private val timezone: JsonField, - private val url: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun disclaimer(): Optional = - Optional.ofNullable(disclaimer.getNullable("disclaimer")) - - fun email(): Optional = Optional.ofNullable(email.getNullable("email")) - - fun fareUrl(): Optional = Optional.ofNullable(fareUrl.getNullable("fareUrl")) - - fun id(): String = id.getRequired("id") - - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - - fun name(): String = name.getRequired("name") - - fun phone(): Optional = Optional.ofNullable(phone.getNullable("phone")) - - fun privateService(): Optional = - Optional.ofNullable(privateService.getNullable("privateService")) - - fun timezone(): String = timezone.getRequired("timezone") - - fun url(): String = url.getRequired("url") - - @JsonProperty("disclaimer") @ExcludeMissing fun _disclaimer() = disclaimer - - @JsonProperty("email") @ExcludeMissing fun _email() = email - - @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl() = fareUrl - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("phone") @ExcludeMissing fun _phone() = phone - - @JsonProperty("privateService") @ExcludeMissing fun _privateService() = privateService - - @JsonProperty("timezone") @ExcludeMissing fun _timezone() = timezone - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - disclaimer() - email() - fareUrl() - id() - lang() - name() - phone() - privateService() - timezone() - url() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var disclaimer: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var fareUrl: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var lang: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var phone: JsonField = JsonMissing.of() - private var privateService: JsonField = JsonMissing.of() - private var timezone: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.disclaimer = entry.disclaimer - this.email = entry.email - this.fareUrl = entry.fareUrl - this.id = entry.id - this.lang = entry.lang - this.name = entry.name - this.phone = entry.phone - this.privateService = entry.privateService - this.timezone = entry.timezone - this.url = entry.url - additionalProperties(entry.additionalProperties) - } - - fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) - - @JsonProperty("disclaimer") - @ExcludeMissing - fun disclaimer(disclaimer: JsonField) = apply { - this.disclaimer = disclaimer - } - - fun email(email: String) = email(JsonField.of(email)) - - @JsonProperty("email") - @ExcludeMissing - fun email(email: JsonField) = apply { this.email = email } - - fun fareUrl(fareUrl: String) = fareUrl(JsonField.of(fareUrl)) - - @JsonProperty("fareUrl") - @ExcludeMissing - fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun lang(lang: String) = lang(JsonField.of(lang)) - - @JsonProperty("lang") - @ExcludeMissing - fun lang(lang: JsonField) = apply { this.lang = lang } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun phone(phone: String) = phone(JsonField.of(phone)) - - @JsonProperty("phone") - @ExcludeMissing - fun phone(phone: JsonField) = apply { this.phone = phone } - - fun privateService(privateService: Boolean) = - privateService(JsonField.of(privateService)) - - @JsonProperty("privateService") - @ExcludeMissing - fun privateService(privateService: JsonField) = apply { - this.privateService = privateService - } - - fun timezone(timezone: String) = timezone(JsonField.of(timezone)) - - @JsonProperty("timezone") - @ExcludeMissing - fun timezone(timezone: JsonField) = apply { this.timezone = timezone } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - disclaimer, - email, - fareUrl, - id, - lang, - name, - phone, - privateService, - timezone, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.disclaimer == other.disclaimer && this.email == other.email && this.fareUrl == other.fareUrl && this.id == other.id && this.lang == other.lang && this.name == other.name && this.phone == other.phone && this.privateService == other.privateService && this.timezone == other.timezone && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(disclaimer, email, fareUrl, id, lang, name, phone, privateService, timezone, url, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, id=$id, lang=$lang, name=$name, phone=$phone, privateService=$privateService, timezone=$timezone, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AgencyRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "AgencyRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt deleted file mode 100644 index 10d7678..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt +++ /dev/null @@ -1,201 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class ArrivalAndDepartureListParams -constructor( - private val stopId: String, - private val minutesAfter: Long?, - private val minutesBefore: Long?, - private val time: OffsetDateTime?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun stopId(): String = stopId - - fun minutesAfter(): Optional = Optional.ofNullable(minutesAfter) - - fun minutesBefore(): Optional = Optional.ofNullable(minutesBefore) - - fun time(): Optional = Optional.ofNullable(time) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.minutesAfter?.let { params.put("minutesAfter", listOf(it.toString())) } - this.minutesBefore?.let { params.put("minutesBefore", listOf(it.toString())) } - this.time?.let { - params.put("time", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) - } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ArrivalAndDepartureListParams && this.stopId == other.stopId && this.minutesAfter == other.minutesAfter && this.minutesBefore == other.minutesBefore && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, minutesAfter, minutesBefore, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ArrivalAndDepartureListParams{stopId=$stopId, minutesAfter=$minutesAfter, minutesBefore=$minutesBefore, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var stopId: String? = null - private var minutesAfter: Long? = null - private var minutesBefore: Long? = null - private var time: OffsetDateTime? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(arrivalAndDepartureListParams: ArrivalAndDepartureListParams) = apply { - this.stopId = arrivalAndDepartureListParams.stopId - this.minutesAfter = arrivalAndDepartureListParams.minutesAfter - this.minutesBefore = arrivalAndDepartureListParams.minutesBefore - this.time = arrivalAndDepartureListParams.time - additionalHeaders(arrivalAndDepartureListParams.additionalHeaders) - additionalQueryParams(arrivalAndDepartureListParams.additionalQueryParams) - } - - fun stopId(stopId: String) = apply { this.stopId = stopId } - - /** Include vehicles arriving or departing in the next n minutes. */ - fun minutesAfter(minutesAfter: Long) = apply { this.minutesAfter = minutesAfter } - - /** Include vehicles having arrived or departed in the previous n minutes. */ - fun minutesBefore(minutesBefore: Long) = apply { this.minutesBefore = minutesBefore } - - /** The specific time for querying the system status. */ - fun time(time: OffsetDateTime) = apply { this.time = time } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): ArrivalAndDepartureListParams = - ArrivalAndDepartureListParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, - minutesAfter, - minutesBefore, - time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt deleted file mode 100644 index 1bd13ba..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt +++ /dev/null @@ -1,2445 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = ArrivalAndDepartureListResponse.Builder::class) -@NoAutoDetect -class ArrivalAndDepartureListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ArrivalAndDepartureListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(arrivalAndDepartureListResponse: ArrivalAndDepartureListResponse) = - apply { - this.code = arrivalAndDepartureListResponse.code - this.currentTime = arrivalAndDepartureListResponse.currentTime - this.text = arrivalAndDepartureListResponse.text - this.version = arrivalAndDepartureListResponse.version - this.data = arrivalAndDepartureListResponse.data - additionalProperties(arrivalAndDepartureListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ArrivalAndDepartureListResponse = - ArrivalAndDepartureListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val arrivalsAndDepartures: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arrivalsAndDepartures(): List = - arrivalsAndDepartures.getRequired("arrivalsAndDepartures") - - @JsonProperty("arrivalsAndDepartures") - @ExcludeMissing - fun _arrivalsAndDepartures() = arrivalsAndDepartures - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - arrivalsAndDepartures().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arrivalsAndDepartures: JsonField> = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.arrivalsAndDepartures = entry.arrivalsAndDepartures - additionalProperties(entry.additionalProperties) - } - - fun arrivalsAndDepartures(arrivalsAndDepartures: List) = - arrivalsAndDepartures(JsonField.of(arrivalsAndDepartures)) - - @JsonProperty("arrivalsAndDepartures") - @ExcludeMissing - fun arrivalsAndDepartures( - arrivalsAndDepartures: JsonField> - ) = apply { this.arrivalsAndDepartures = arrivalsAndDepartures } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - arrivalsAndDepartures.map { it.toImmutable() }, - additionalProperties.toImmutable() - ) - } - - @JsonDeserialize(builder = ArrivalsAndDeparture.Builder::class) - @NoAutoDetect - class ArrivalsAndDeparture - private constructor( - private val actualTrack: JsonField, - private val arrivalEnabled: JsonField, - private val blockTripSequence: JsonField, - private val departureEnabled: JsonField, - private val distanceFromStop: JsonField, - private val frequency: JsonField, - private val historicalOccupancy: JsonField, - private val lastUpdateTime: JsonField, - private val numberOfStopsAway: JsonField, - private val occupancyStatus: JsonField, - private val predicted: JsonField, - private val predictedArrivalInterval: JsonField, - private val predictedArrivalTime: JsonField, - private val predictedDepartureInterval: JsonField, - private val predictedDepartureTime: JsonField, - private val predictedOccupancy: JsonField, - private val routeId: JsonField, - private val routeLongName: JsonField, - private val routeShortName: JsonField, - private val scheduledArrivalInterval: JsonField, - private val scheduledArrivalTime: JsonField, - private val scheduledDepartureInterval: JsonField, - private val scheduledDepartureTime: JsonField, - private val scheduledTrack: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val stopId: JsonField, - private val stopSequence: JsonField, - private val totalStopsInTrip: JsonField, - private val tripHeadsign: JsonField, - private val tripId: JsonField, - private val tripStatus: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(): Optional = - Optional.ofNullable(actualTrack.getNullable("actualTrack")) - - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** Indicates if riders can depart from this transit vehicle. */ - fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - fun distanceFromStop(): Optional = - Optional.ofNullable(distanceFromStop.getNullable("distanceFromStop")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Historical occupancy information of the transit vehicle. */ - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - /** Timestamp of the last update time for this arrival. */ - fun lastUpdateTime(): Optional = - Optional.ofNullable(lastUpdateTime.getNullable("lastUpdateTime")) - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): Optional = - Optional.ofNullable(occupancyStatus.getNullable("occupancyStatus")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Optional = - Optional.ofNullable(predicted.getNullable("predicted")) - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(): Optional = - Optional.ofNullable( - predictedArrivalInterval.getNullable("predictedArrivalInterval") - ) - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(): Long = - predictedArrivalTime.getRequired("predictedArrivalTime") - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(): Optional = - Optional.ofNullable( - predictedDepartureInterval.getNullable("predictedDepartureInterval") - ) - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(): Long = - predictedDepartureTime.getRequired("predictedDepartureTime") - - /** Predicted occupancy status of the transit vehicle. */ - fun predictedOccupancy(): Optional = - Optional.ofNullable(predictedOccupancy.getNullable("predictedOccupancy")) - - /** The ID of the route for the arriving vehicle. */ - fun routeId(): String = routeId.getRequired("routeId") - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - fun routeLongName(): Optional = - Optional.ofNullable(routeLongName.getNullable("routeLongName")) - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(): Optional = - Optional.ofNullable( - scheduledArrivalInterval.getNullable("scheduledArrivalInterval") - ) - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(): Long = - scheduledArrivalTime.getRequired("scheduledArrivalTime") - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(): Optional = - Optional.ofNullable( - scheduledDepartureInterval.getNullable("scheduledDepartureInterval") - ) - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(): Long = - scheduledDepartureTime.getRequired("scheduledDepartureTime") - - /** Scheduled track information of the arriving transit vehicle. */ - fun scheduledTrack(): Optional = - Optional.ofNullable(scheduledTrack.getNullable("scheduledTrack")) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this arrival. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status of the arrival. */ - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(): String = stopId.getRequired("stopId") - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - fun stopSequence(): Long = stopSequence.getRequired("stopSequence") - - /** Total number of stops visited on the trip for this arrival. */ - fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(): String = tripId.getRequired("tripId") - - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(): Optional = - Optional.ofNullable(tripStatus.getNullable("tripStatus")) - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") @ExcludeMissing fun _actualTrack() = actualTrack - - /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun _arrivalEnabled() = arrivalEnabled - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** Indicates if riders can depart from this transit vehicle. */ - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled() = departureEnabled - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing - fun _distanceFromStop() = distanceFromStop - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy - - /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - fun _numberOfStopsAway() = numberOfStopsAway - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - fun _predictedArrivalInterval() = predictedArrivalInterval - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - fun _predictedArrivalTime() = predictedArrivalTime - - /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - fun _predictedDepartureInterval() = predictedDepartureInterval - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - fun _predictedDepartureTime() = predictedDepartureTime - - /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing - fun _predictedOccupancy() = predictedOccupancy - - /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - @JsonProperty("routeLongName") @ExcludeMissing fun _routeLongName() = routeLongName - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - @JsonProperty("routeShortName") - @ExcludeMissing - fun _routeShortName() = routeShortName - - /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - fun _scheduledArrivalInterval() = scheduledArrivalInterval - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - fun _scheduledArrivalTime() = scheduledArrivalTime - - /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - fun _scheduledDepartureInterval() = scheduledDepartureInterval - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - fun _scheduledDepartureTime() = scheduledDepartureTime - - /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") - @ExcludeMissing - fun _scheduledTrack() = scheduledTrack - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status of the arrival. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - @JsonProperty("stopSequence") @ExcludeMissing fun _stopSequence() = stopSequence - - /** Total number of stops visited on the trip for this arrival. */ - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - fun _totalStopsInTrip() = totalStopsInTrip - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign - - /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") @ExcludeMissing fun _tripStatus() = tripStatus - - /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ArrivalsAndDeparture = apply { - if (!validated) { - actualTrack() - arrivalEnabled() - blockTripSequence() - departureEnabled() - distanceFromStop() - frequency() - historicalOccupancy() - lastUpdateTime() - numberOfStopsAway() - occupancyStatus() - predicted() - predictedArrivalInterval() - predictedArrivalTime() - predictedDepartureInterval() - predictedDepartureTime() - predictedOccupancy() - routeId() - routeLongName() - routeShortName() - scheduledArrivalInterval() - scheduledArrivalTime() - scheduledDepartureInterval() - scheduledDepartureTime() - scheduledTrack() - serviceDate() - situationIds() - status() - stopId() - stopSequence() - totalStopsInTrip() - tripHeadsign() - tripId() - tripStatus().map { it.validate() } - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var actualTrack: JsonField = JsonMissing.of() - private var arrivalEnabled: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var departureEnabled: JsonField = JsonMissing.of() - private var distanceFromStop: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var historicalOccupancy: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var numberOfStopsAway: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var predictedArrivalInterval: JsonField = JsonMissing.of() - private var predictedArrivalTime: JsonField = JsonMissing.of() - private var predictedDepartureInterval: JsonField = JsonMissing.of() - private var predictedDepartureTime: JsonField = JsonMissing.of() - private var predictedOccupancy: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() - private var routeLongName: JsonField = JsonMissing.of() - private var routeShortName: JsonField = JsonMissing.of() - private var scheduledArrivalInterval: JsonField = JsonMissing.of() - private var scheduledArrivalTime: JsonField = JsonMissing.of() - private var scheduledDepartureInterval: JsonField = JsonMissing.of() - private var scheduledDepartureTime: JsonField = JsonMissing.of() - private var scheduledTrack: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var stopSequence: JsonField = JsonMissing.of() - private var totalStopsInTrip: JsonField = JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var tripStatus: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { - this.actualTrack = arrivalsAndDeparture.actualTrack - this.arrivalEnabled = arrivalsAndDeparture.arrivalEnabled - this.blockTripSequence = arrivalsAndDeparture.blockTripSequence - this.departureEnabled = arrivalsAndDeparture.departureEnabled - this.distanceFromStop = arrivalsAndDeparture.distanceFromStop - this.frequency = arrivalsAndDeparture.frequency - this.historicalOccupancy = arrivalsAndDeparture.historicalOccupancy - this.lastUpdateTime = arrivalsAndDeparture.lastUpdateTime - this.numberOfStopsAway = arrivalsAndDeparture.numberOfStopsAway - this.occupancyStatus = arrivalsAndDeparture.occupancyStatus - this.predicted = arrivalsAndDeparture.predicted - this.predictedArrivalInterval = - arrivalsAndDeparture.predictedArrivalInterval - this.predictedArrivalTime = arrivalsAndDeparture.predictedArrivalTime - this.predictedDepartureInterval = - arrivalsAndDeparture.predictedDepartureInterval - this.predictedDepartureTime = arrivalsAndDeparture.predictedDepartureTime - this.predictedOccupancy = arrivalsAndDeparture.predictedOccupancy - this.routeId = arrivalsAndDeparture.routeId - this.routeLongName = arrivalsAndDeparture.routeLongName - this.routeShortName = arrivalsAndDeparture.routeShortName - this.scheduledArrivalInterval = - arrivalsAndDeparture.scheduledArrivalInterval - this.scheduledArrivalTime = arrivalsAndDeparture.scheduledArrivalTime - this.scheduledDepartureInterval = - arrivalsAndDeparture.scheduledDepartureInterval - this.scheduledDepartureTime = arrivalsAndDeparture.scheduledDepartureTime - this.scheduledTrack = arrivalsAndDeparture.scheduledTrack - this.serviceDate = arrivalsAndDeparture.serviceDate - this.situationIds = arrivalsAndDeparture.situationIds - this.status = arrivalsAndDeparture.status - this.stopId = arrivalsAndDeparture.stopId - this.stopSequence = arrivalsAndDeparture.stopSequence - this.totalStopsInTrip = arrivalsAndDeparture.totalStopsInTrip - this.tripHeadsign = arrivalsAndDeparture.tripHeadsign - this.tripId = arrivalsAndDeparture.tripId - this.tripStatus = arrivalsAndDeparture.tripStatus - this.vehicleId = arrivalsAndDeparture.vehicleId - additionalProperties(arrivalsAndDeparture.additionalProperties) - } - - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) - - /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") - @ExcludeMissing - fun actualTrack(actualTrack: JsonField) = apply { - this.actualTrack = actualTrack - } - - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(arrivalEnabled: Boolean) = - arrivalEnabled(JsonField.of(arrivalEnabled)) - - /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun arrivalEnabled(arrivalEnabled: JsonField) = apply { - this.arrivalEnabled = arrivalEnabled - } - - /** - * Index of this arrival’s trip into the sequence of trips for the active block. - */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** - * Index of this arrival’s trip into the sequence of trips for the active block. - */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** Indicates if riders can depart from this transit vehicle. */ - fun departureEnabled(departureEnabled: Boolean) = - departureEnabled(JsonField.of(departureEnabled)) - - /** Indicates if riders can depart from this transit vehicle. */ - @JsonProperty("departureEnabled") - @ExcludeMissing - fun departureEnabled(departureEnabled: JsonField) = apply { - this.departureEnabled = departureEnabled - } - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - fun distanceFromStop(distanceFromStop: Double) = - distanceFromStop(JsonField.of(distanceFromStop)) - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing - fun distanceFromStop(distanceFromStop: JsonField) = apply { - this.distanceFromStop = distanceFromStop - } - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** Historical occupancy information of the transit vehicle. */ - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - /** Timestamp of the last update time for this arrival. */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(numberOfStopsAway: Long) = - numberOfStopsAway(JsonField.of(numberOfStopsAway)) - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { - this.numberOfStopsAway = numberOfStopsAway - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: String) = - predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) - - /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = - apply { - this.predictedArrivalInterval = predictedArrivalInterval - } - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - fun predictedArrivalTime(predictedArrivalTime: Long) = - predictedArrivalTime(JsonField.of(predictedArrivalTime)) - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { - this.predictedArrivalTime = predictedArrivalTime - } - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: String) = - predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) - - /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = - apply { - this.predictedDepartureInterval = predictedDepartureInterval - } - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - fun predictedDepartureTime(predictedDepartureTime: Long) = - predictedDepartureTime(JsonField.of(predictedDepartureTime)) - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { - this.predictedDepartureTime = predictedDepartureTime - } - - /** Predicted occupancy status of the transit vehicle. */ - fun predictedOccupancy(predictedOccupancy: String) = - predictedOccupancy(JsonField.of(predictedOccupancy)) - - /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing - fun predictedOccupancy(predictedOccupancy: JsonField) = apply { - this.predictedOccupancy = predictedOccupancy - } - - /** The ID of the route for the arriving vehicle. */ - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") - @ExcludeMissing - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - /** - * Optional route long name that potentially overrides the route long name in - * the referenced route element. - */ - fun routeLongName(routeLongName: String) = - routeLongName(JsonField.of(routeLongName)) - - /** - * Optional route long name that potentially overrides the route long name in - * the referenced route element. - */ - @JsonProperty("routeLongName") - @ExcludeMissing - fun routeLongName(routeLongName: JsonField) = apply { - this.routeLongName = routeLongName - } - - /** - * Optional route short name that potentially overrides the route short name in - * the referenced route element. - */ - fun routeShortName(routeShortName: String) = - routeShortName(JsonField.of(routeShortName)) - - /** - * Optional route short name that potentially overrides the route short name in - * the referenced route element. - */ - @JsonProperty("routeShortName") - @ExcludeMissing - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: String) = - scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) - - /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = - apply { - this.scheduledArrivalInterval = scheduledArrivalInterval - } - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: Long) = - scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { - this.scheduledArrivalTime = scheduledArrivalTime - } - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: String) = - scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) - - /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = - apply { - this.scheduledDepartureInterval = scheduledDepartureInterval - } - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(scheduledDepartureTime: Long) = - scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { - this.scheduledDepartureTime = scheduledDepartureTime - } - - /** Scheduled track information of the arriving transit vehicle. */ - fun scheduledTrack(scheduledTrack: String) = - scheduledTrack(JsonField.of(scheduledTrack)) - - /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") - @ExcludeMissing - fun scheduledTrack(scheduledTrack: JsonField) = apply { - this.scheduledTrack = scheduledTrack - } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this arrival. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - /** Current status of the arrival. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status of the arrival. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - fun stopSequence(stopSequence: Long) = stopSequence(JsonField.of(stopSequence)) - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - @JsonProperty("stopSequence") - @ExcludeMissing - fun stopSequence(stopSequence: JsonField) = apply { - this.stopSequence = stopSequence - } - - /** Total number of stops visited on the trip for this arrival. */ - fun totalStopsInTrip(totalStopsInTrip: Long) = - totalStopsInTrip(JsonField.of(totalStopsInTrip)) - - /** Total number of stops visited on the trip for this arrival. */ - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { - this.totalStopsInTrip = totalStopsInTrip - } - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - fun tripHeadsign(tripHeadsign: String) = - tripHeadsign(JsonField.of(tripHeadsign)) - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") - @ExcludeMissing - fun tripStatus(tripStatus: JsonField) = apply { - this.tripStatus = tripStatus - } - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ArrivalsAndDeparture = - ArrivalsAndDeparture( - actualTrack, - arrivalEnabled, - blockTripSequence, - departureEnabled, - distanceFromStop, - frequency, - historicalOccupancy, - lastUpdateTime, - numberOfStopsAway, - occupancyStatus, - predicted, - predictedArrivalInterval, - predictedArrivalTime, - predictedDepartureInterval, - predictedDepartureTime, - predictedOccupancy, - routeId, - routeLongName, - routeShortName, - scheduledArrivalInterval, - scheduledArrivalTime, - scheduledDepartureInterval, - scheduledDepartureTime, - scheduledTrack, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - stopId, - stopSequence, - totalStopsInTrip, - tripHeadsign, - tripId, - tripStatus, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonDeserialize(builder = TripStatus.Builder::class) - @NoAutoDetect - class TripStatus - private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = - blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable( - closestStopTimeOffset.getNullable("closestStopTimeOffset") - ) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(): Double = - distanceAlongTrip.getRequired("distanceAlongTrip") - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable( - lastKnownOrientation.getNullable("lastKnownOrientation") - ) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = - occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - fun scheduleDeviation(): Long = - scheduleDeviation.getRequired("scheduleDeviation") - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount() = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripStatus = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() - private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() - private var lastKnownLocation: JsonField = - JsonMissing.of() - private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var nextStop: JsonField = JsonMissing.of() - private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() - private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tripStatus: TripStatus) = apply { - this.activeTripId = tripStatus.activeTripId - this.blockTripSequence = tripStatus.blockTripSequence - this.closestStop = tripStatus.closestStop - this.closestStopTimeOffset = tripStatus.closestStopTimeOffset - this.distanceAlongTrip = tripStatus.distanceAlongTrip - this.frequency = tripStatus.frequency - this.lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - this.lastKnownLocation = tripStatus.lastKnownLocation - this.lastKnownOrientation = tripStatus.lastKnownOrientation - this.lastLocationUpdateTime = tripStatus.lastLocationUpdateTime - this.lastUpdateTime = tripStatus.lastUpdateTime - this.nextStop = tripStatus.nextStop - this.nextStopTimeOffset = tripStatus.nextStopTimeOffset - this.occupancyCapacity = tripStatus.occupancyCapacity - this.occupancyCount = tripStatus.occupancyCount - this.occupancyStatus = tripStatus.occupancyStatus - this.orientation = tripStatus.orientation - this.phase = tripStatus.phase - this.position = tripStatus.position - this.predicted = tripStatus.predicted - this.scheduleDeviation = tripStatus.scheduleDeviation - this.scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip - this.serviceDate = tripStatus.serviceDate - this.situationIds = tripStatus.situationIds - this.status = tripStatus.status - this.totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip - this.vehicleId = tripStatus.vehicleId - additionalProperties(tripStatus.additionalProperties) - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun activeTripId(activeTripId: JsonField) = apply { - this.activeTripId = activeTripId - } - - /** - * Index of the active trip into the sequence of trips for the active block. - */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** - * Index of the active trip into the sequence of trips for the active block. - */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** - * ID of the closest stop to the current location of the transit vehicle. - */ - fun closestStop(closestStop: String) = - closestStop(JsonField.of(closestStop)) - - /** - * ID of the closest stop to the current location of the transit vehicle. - */ - @JsonProperty("closestStop") - @ExcludeMissing - fun closestStop(closestStop: JsonField) = apply { - this.closestStop = closestStop - } - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - /** - * Information about frequency-based scheduling, if applicable to the trip. - */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** - * Information about frequency-based scheduling, if applicable to the trip. - */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = - lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun lastKnownDistanceAlongTrip( - lastKnownDistanceAlongTrip: JsonField - ) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun lastKnownLocation(lastKnownLocation: JsonField) = - apply { - this.lastKnownLocation = lastKnownLocation - } - - /** - * Last known orientation value received in real-time from the transit - * vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: Double) = - lastKnownOrientation(JsonField.of(lastKnownOrientation)) - - /** - * Last known orientation value received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = - apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - /** - * Timestamp of the last known real-time update from the transit vehicle. - */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** - * Timestamp of the last known real-time update from the transit vehicle. - */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun nextStop(nextStop: JsonField) = apply { - this.nextStop = nextStop - } - - /** - * Time offset from the next stop to the current position of the transit - * vehicle (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: Long) = - nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) - - /** - * Time offset from the next stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** - * Orientation of the transit vehicle, represented as an angle in degrees. - */ - fun orientation(orientation: Double) = - orientation(JsonField.of(orientation)) - - /** - * Orientation of the transit vehicle, represented as an angle in degrees. - */ - @JsonProperty("orientation") - @ExcludeMissing - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing - fun phase(phase: JsonField) = apply { this.phase = phase } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - fun scheduleDeviation(scheduleDeviation: Long) = - scheduleDeviation(JsonField.of(scheduleDeviation)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun scheduleDeviation(scheduleDeviation: JsonField) = apply { - this.scheduleDeviation = scheduleDeviation - } - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun scheduledDistanceAlongTrip( - scheduledDistanceAlongTrip: JsonField - ) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of - * the service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of - * the service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = - apply { - this.totalDistanceAlongTrip = totalDistanceAlongTrip - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): TripStatus = - TripStatus( - activeTripId, - blockTripSequence, - closestStop, - closestStopTimeOffset, - distanceAlongTrip, - frequency, - lastKnownDistanceAlongTrip, - lastKnownLocation, - lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, - nextStop, - nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, - orientation, - phase, - position, - predicted, - scheduleDeviation, - scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) - @NoAutoDetect - class LastKnownLocation - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) - } - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) - @NoAutoDetect - class Position - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) - } - - /** Latitude of the current position of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the current position of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripStatus && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ArrivalsAndDeparture && this.actualTrack == other.actualTrack && this.arrivalEnabled == other.arrivalEnabled && this.blockTripSequence == other.blockTripSequence && this.departureEnabled == other.departureEnabled && this.distanceFromStop == other.distanceFromStop && this.frequency == other.frequency && this.historicalOccupancy == other.historicalOccupancy && this.lastUpdateTime == other.lastUpdateTime && this.numberOfStopsAway == other.numberOfStopsAway && this.occupancyStatus == other.occupancyStatus && this.predicted == other.predicted && this.predictedArrivalInterval == other.predictedArrivalInterval && this.predictedArrivalTime == other.predictedArrivalTime && this.predictedDepartureInterval == other.predictedDepartureInterval && this.predictedDepartureTime == other.predictedDepartureTime && this.predictedOccupancy == other.predictedOccupancy && this.routeId == other.routeId && this.routeLongName == other.routeLongName && this.routeShortName == other.routeShortName && this.scheduledArrivalInterval == other.scheduledArrivalInterval && this.scheduledArrivalTime == other.scheduledArrivalTime && this.scheduledDepartureInterval == other.scheduledDepartureInterval && this.scheduledDepartureTime == other.scheduledDepartureTime && this.scheduledTrack == other.scheduledTrack && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.stopId == other.stopId && this.stopSequence == other.stopSequence && this.totalStopsInTrip == other.totalStopsInTrip && this.tripHeadsign == other.tripHeadsign && this.tripId == other.tripId && this.tripStatus == other.tripStatus && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(actualTrack, arrivalEnabled, blockTripSequence, departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, predictedArrivalTime, predictedDepartureInterval, predictedDepartureTime, predictedOccupancy, routeId, routeLongName, routeShortName, scheduledArrivalInterval, scheduledArrivalTime, scheduledDepartureInterval, scheduledDepartureTime, scheduledTrack, serviceDate, situationIds, status, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, tripStatus, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ArrivalsAndDeparture{actualTrack=$actualTrack, arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, numberOfStopsAway=$numberOfStopsAway, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedArrivalTime=$predictedArrivalTime, predictedDepartureInterval=$predictedDepartureInterval, predictedDepartureTime=$predictedDepartureTime, predictedOccupancy=$predictedOccupancy, routeId=$routeId, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledDepartureTime=$scheduledDepartureTime, scheduledTrack=$scheduledTrack, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, tripStatus=$tripStatus, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.arrivalsAndDepartures == other.arrivalsAndDepartures && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalsAndDepartures, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{arrivalsAndDepartures=$arrivalsAndDepartures, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ArrivalAndDepartureListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ArrivalAndDepartureListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt deleted file mode 100644 index a4890f6..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt +++ /dev/null @@ -1,213 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class ArrivalAndDepartureRetrieveParams -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: Map>, - private val additionalQueryParams: Map>, -) { - - fun stopId(): String = 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) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.serviceDate.let { params.put("serviceDate", listOf(it.toString())) } - this.tripId.let { params.put("tripId", listOf(it.toString())) } - this.stopSequence?.let { params.put("stopSequence", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - this.vehicleId?.let { params.put("vehicleId", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ArrivalAndDepartureRetrieveParams && this.stopId == other.stopId && this.serviceDate == other.serviceDate && this.tripId == other.tripId && this.stopSequence == other.stopSequence && this.time == other.time && this.vehicleId == other.vehicleId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, serviceDate, tripId, stopSequence, time, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ArrivalAndDepartureRetrieveParams{stopId=$stopId, serviceDate=$serviceDate, tripId=$tripId, stopSequence=$stopSequence, time=$time, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - 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: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(arrivalAndDepartureRetrieveParams: ArrivalAndDepartureRetrieveParams) = - apply { - this.stopId = arrivalAndDepartureRetrieveParams.stopId - this.serviceDate = arrivalAndDepartureRetrieveParams.serviceDate - this.tripId = arrivalAndDepartureRetrieveParams.tripId - this.stopSequence = arrivalAndDepartureRetrieveParams.stopSequence - this.time = arrivalAndDepartureRetrieveParams.time - this.vehicleId = arrivalAndDepartureRetrieveParams.vehicleId - additionalHeaders(arrivalAndDepartureRetrieveParams.additionalHeaders) - additionalQueryParams(arrivalAndDepartureRetrieveParams.additionalQueryParams) - } - - fun stopId(stopId: String) = apply { this.stopId = stopId } - - fun serviceDate(serviceDate: Long) = apply { this.serviceDate = serviceDate } - - fun tripId(tripId: String) = apply { this.tripId = tripId } - - fun stopSequence(stopSequence: Long) = apply { this.stopSequence = stopSequence } - - fun time(time: Long) = apply { this.time = time } - - fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): ArrivalAndDepartureRetrieveParams = - ArrivalAndDepartureRetrieveParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, - checkNotNull(serviceDate) { "`serviceDate` is required but was not set" }, - checkNotNull(tripId) { "`tripId` is required but was not set" }, - stopSequence, - time, - vehicleId, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt deleted file mode 100644 index eaa7107..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt +++ /dev/null @@ -1,2271 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = ArrivalAndDepartureRetrieveResponse.Builder::class) -@NoAutoDetect -class ArrivalAndDepartureRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ArrivalAndDepartureRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - arrivalAndDepartureRetrieveResponse: ArrivalAndDepartureRetrieveResponse - ) = apply { - this.code = arrivalAndDepartureRetrieveResponse.code - this.currentTime = arrivalAndDepartureRetrieveResponse.currentTime - this.text = arrivalAndDepartureRetrieveResponse.text - this.version = arrivalAndDepartureRetrieveResponse.version - this.data = arrivalAndDepartureRetrieveResponse.data - additionalProperties(arrivalAndDepartureRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ArrivalAndDepartureRetrieveResponse = - ArrivalAndDepartureRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val actualTrack: JsonField, - private val arrivalEnabled: JsonField, - private val blockTripSequence: JsonField, - private val departureEnabled: JsonField, - private val distanceFromStop: JsonField, - private val frequency: JsonField, - private val historicalOccupancy: JsonField, - private val lastUpdateTime: JsonField, - private val numberOfStopsAway: JsonField, - private val occupancyStatus: JsonField, - private val predicted: JsonField, - private val predictedArrivalInterval: JsonField, - private val predictedArrivalTime: JsonField, - private val predictedDepartureInterval: JsonField, - private val predictedDepartureTime: JsonField, - private val predictedOccupancy: JsonField, - private val routeId: JsonField, - private val routeLongName: JsonField, - private val routeShortName: JsonField, - private val scheduledArrivalInterval: JsonField, - private val scheduledArrivalTime: JsonField, - private val scheduledDepartureInterval: JsonField, - private val scheduledDepartureTime: JsonField, - private val scheduledTrack: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val stopId: JsonField, - private val stopSequence: JsonField, - private val totalStopsInTrip: JsonField, - private val tripHeadsign: JsonField, - private val tripId: JsonField, - private val tripStatus: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(): Optional = - Optional.ofNullable(actualTrack.getNullable("actualTrack")) - - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** Indicates if riders can depart from this transit vehicle. */ - fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - fun distanceFromStop(): Optional = - Optional.ofNullable(distanceFromStop.getNullable("distanceFromStop")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Historical occupancy information of the transit vehicle. */ - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - /** Timestamp of the last update time for this arrival. */ - fun lastUpdateTime(): Optional = - Optional.ofNullable(lastUpdateTime.getNullable("lastUpdateTime")) - - /** - * Number of stops between the arriving transit vehicle and the current stop (excluding - * the current stop). - */ - fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): Optional = - Optional.ofNullable(occupancyStatus.getNullable("occupancyStatus")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Optional = - Optional.ofNullable(predicted.getNullable("predicted")) - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(): Optional = - Optional.ofNullable( - predictedArrivalInterval.getNullable("predictedArrivalInterval") - ) - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(): Long = - predictedArrivalTime.getRequired("predictedArrivalTime") - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(): Optional = - Optional.ofNullable( - predictedDepartureInterval.getNullable("predictedDepartureInterval") - ) - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(): Long = - predictedDepartureTime.getRequired("predictedDepartureTime") - - /** Predicted occupancy status of the transit vehicle. */ - fun predictedOccupancy(): Optional = - Optional.ofNullable(predictedOccupancy.getNullable("predictedOccupancy")) - - /** The ID of the route for the arriving vehicle. */ - fun routeId(): String = routeId.getRequired("routeId") - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - fun routeLongName(): Optional = - Optional.ofNullable(routeLongName.getNullable("routeLongName")) - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(): Optional = - Optional.ofNullable( - scheduledArrivalInterval.getNullable("scheduledArrivalInterval") - ) - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(): Long = - scheduledArrivalTime.getRequired("scheduledArrivalTime") - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(): Optional = - Optional.ofNullable( - scheduledDepartureInterval.getNullable("scheduledDepartureInterval") - ) - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(): Long = - scheduledDepartureTime.getRequired("scheduledDepartureTime") - - /** Scheduled track information of the arriving transit vehicle. */ - fun scheduledTrack(): Optional = - Optional.ofNullable(scheduledTrack.getNullable("scheduledTrack")) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the service - * date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this arrival. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status of the arrival. */ - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(): String = stopId.getRequired("stopId") - - /** - * Index of the stop into the sequence of stops that make up the trip for this arrival. - */ - fun stopSequence(): Long = stopSequence.getRequired("stopSequence") - - /** Total number of stops visited on the trip for this arrival. */ - fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") - - /** - * Optional trip headsign that potentially overrides the trip headsign in the referenced - * trip element. - */ - fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(): String = tripId.getRequired("tripId") - - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(): Optional = - Optional.ofNullable(tripStatus.getNullable("tripStatus")) - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") @ExcludeMissing fun _actualTrack() = actualTrack - - /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") @ExcludeMissing fun _arrivalEnabled() = arrivalEnabled - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** Indicates if riders can depart from this transit vehicle. */ - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled() = departureEnabled - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing - fun _distanceFromStop() = distanceFromStop - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy - - /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") @ExcludeMissing fun _lastUpdateTime() = lastUpdateTime - - /** - * Number of stops between the arriving transit vehicle and the current stop (excluding - * the current stop). - */ - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - fun _numberOfStopsAway() = numberOfStopsAway - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - fun _predictedArrivalInterval() = predictedArrivalInterval - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - fun _predictedArrivalTime() = predictedArrivalTime - - /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - fun _predictedDepartureInterval() = predictedDepartureInterval - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - fun _predictedDepartureTime() = predictedDepartureTime - - /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing - fun _predictedOccupancy() = predictedOccupancy - - /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - @JsonProperty("routeLongName") @ExcludeMissing fun _routeLongName() = routeLongName - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - @JsonProperty("routeShortName") @ExcludeMissing fun _routeShortName() = routeShortName - - /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - fun _scheduledArrivalInterval() = scheduledArrivalInterval - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - fun _scheduledArrivalTime() = scheduledArrivalTime - - /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - fun _scheduledDepartureInterval() = scheduledDepartureInterval - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - fun _scheduledDepartureTime() = scheduledDepartureTime - - /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") @ExcludeMissing fun _scheduledTrack() = scheduledTrack - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the service - * date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status of the arrival. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - /** - * Index of the stop into the sequence of stops that make up the trip for this arrival. - */ - @JsonProperty("stopSequence") @ExcludeMissing fun _stopSequence() = stopSequence - - /** Total number of stops visited on the trip for this arrival. */ - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - fun _totalStopsInTrip() = totalStopsInTrip - - /** - * Optional trip headsign that potentially overrides the trip headsign in the referenced - * trip element. - */ - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign - - /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") @ExcludeMissing fun _tripStatus() = tripStatus - - /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - actualTrack() - arrivalEnabled() - blockTripSequence() - departureEnabled() - distanceFromStop() - frequency() - historicalOccupancy() - lastUpdateTime() - numberOfStopsAway() - occupancyStatus() - predicted() - predictedArrivalInterval() - predictedArrivalTime() - predictedDepartureInterval() - predictedDepartureTime() - predictedOccupancy() - routeId() - routeLongName() - routeShortName() - scheduledArrivalInterval() - scheduledArrivalTime() - scheduledDepartureInterval() - scheduledDepartureTime() - scheduledTrack() - serviceDate() - situationIds() - status() - stopId() - stopSequence() - totalStopsInTrip() - tripHeadsign() - tripId() - tripStatus().map { it.validate() } - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var actualTrack: JsonField = JsonMissing.of() - private var arrivalEnabled: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var departureEnabled: JsonField = JsonMissing.of() - private var distanceFromStop: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var historicalOccupancy: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var numberOfStopsAway: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var predictedArrivalInterval: JsonField = JsonMissing.of() - private var predictedArrivalTime: JsonField = JsonMissing.of() - private var predictedDepartureInterval: JsonField = JsonMissing.of() - private var predictedDepartureTime: JsonField = JsonMissing.of() - private var predictedOccupancy: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() - private var routeLongName: JsonField = JsonMissing.of() - private var routeShortName: JsonField = JsonMissing.of() - private var scheduledArrivalInterval: JsonField = JsonMissing.of() - private var scheduledArrivalTime: JsonField = JsonMissing.of() - private var scheduledDepartureInterval: JsonField = JsonMissing.of() - private var scheduledDepartureTime: JsonField = JsonMissing.of() - private var scheduledTrack: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var stopSequence: JsonField = JsonMissing.of() - private var totalStopsInTrip: JsonField = JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var tripStatus: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.actualTrack = entry.actualTrack - this.arrivalEnabled = entry.arrivalEnabled - this.blockTripSequence = entry.blockTripSequence - this.departureEnabled = entry.departureEnabled - this.distanceFromStop = entry.distanceFromStop - this.frequency = entry.frequency - this.historicalOccupancy = entry.historicalOccupancy - this.lastUpdateTime = entry.lastUpdateTime - this.numberOfStopsAway = entry.numberOfStopsAway - this.occupancyStatus = entry.occupancyStatus - this.predicted = entry.predicted - this.predictedArrivalInterval = entry.predictedArrivalInterval - this.predictedArrivalTime = entry.predictedArrivalTime - this.predictedDepartureInterval = entry.predictedDepartureInterval - this.predictedDepartureTime = entry.predictedDepartureTime - this.predictedOccupancy = entry.predictedOccupancy - this.routeId = entry.routeId - this.routeLongName = entry.routeLongName - this.routeShortName = entry.routeShortName - this.scheduledArrivalInterval = entry.scheduledArrivalInterval - this.scheduledArrivalTime = entry.scheduledArrivalTime - this.scheduledDepartureInterval = entry.scheduledDepartureInterval - this.scheduledDepartureTime = entry.scheduledDepartureTime - this.scheduledTrack = entry.scheduledTrack - this.serviceDate = entry.serviceDate - this.situationIds = entry.situationIds - this.status = entry.status - this.stopId = entry.stopId - this.stopSequence = entry.stopSequence - this.totalStopsInTrip = entry.totalStopsInTrip - this.tripHeadsign = entry.tripHeadsign - this.tripId = entry.tripId - this.tripStatus = entry.tripStatus - this.vehicleId = entry.vehicleId - additionalProperties(entry.additionalProperties) - } - - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) - - /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") - @ExcludeMissing - fun actualTrack(actualTrack: JsonField) = apply { - this.actualTrack = actualTrack - } - - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(arrivalEnabled: Boolean) = - arrivalEnabled(JsonField.of(arrivalEnabled)) - - /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun arrivalEnabled(arrivalEnabled: JsonField) = apply { - this.arrivalEnabled = arrivalEnabled - } - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** Indicates if riders can depart from this transit vehicle. */ - fun departureEnabled(departureEnabled: Boolean) = - departureEnabled(JsonField.of(departureEnabled)) - - /** Indicates if riders can depart from this transit vehicle. */ - @JsonProperty("departureEnabled") - @ExcludeMissing - fun departureEnabled(departureEnabled: JsonField) = apply { - this.departureEnabled = departureEnabled - } - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - fun distanceFromStop(distanceFromStop: Double) = - distanceFromStop(JsonField.of(distanceFromStop)) - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing - fun distanceFromStop(distanceFromStop: JsonField) = apply { - this.distanceFromStop = distanceFromStop - } - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - /** Historical occupancy information of the transit vehicle. */ - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - /** Timestamp of the last update time for this arrival. */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(numberOfStopsAway: Long) = - numberOfStopsAway(JsonField.of(numberOfStopsAway)) - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { - this.numberOfStopsAway = numberOfStopsAway - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { this.predicted = predicted } - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: String) = - predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) - - /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = apply { - this.predictedArrivalInterval = predictedArrivalInterval - } - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(predictedArrivalTime: Long) = - predictedArrivalTime(JsonField.of(predictedArrivalTime)) - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { - this.predictedArrivalTime = predictedArrivalTime - } - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: String) = - predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) - - /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = - apply { - this.predictedDepartureInterval = predictedDepartureInterval - } - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(predictedDepartureTime: Long) = - predictedDepartureTime(JsonField.of(predictedDepartureTime)) - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { - this.predictedDepartureTime = predictedDepartureTime - } - - /** Predicted occupancy status of the transit vehicle. */ - fun predictedOccupancy(predictedOccupancy: String) = - predictedOccupancy(JsonField.of(predictedOccupancy)) - - /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing - fun predictedOccupancy(predictedOccupancy: JsonField) = apply { - this.predictedOccupancy = predictedOccupancy - } - - /** The ID of the route for the arriving vehicle. */ - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") - @ExcludeMissing - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - fun routeLongName(routeLongName: String) = - routeLongName(JsonField.of(routeLongName)) - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - @JsonProperty("routeLongName") - @ExcludeMissing - fun routeLongName(routeLongName: JsonField) = apply { - this.routeLongName = routeLongName - } - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - fun routeShortName(routeShortName: String) = - routeShortName(JsonField.of(routeShortName)) - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - @JsonProperty("routeShortName") - @ExcludeMissing - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: String) = - scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) - - /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = apply { - this.scheduledArrivalInterval = scheduledArrivalInterval - } - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: Long) = - scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { - this.scheduledArrivalTime = scheduledArrivalTime - } - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: String) = - scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) - - /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = - apply { - this.scheduledDepartureInterval = scheduledDepartureInterval - } - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(scheduledDepartureTime: Long) = - scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { - this.scheduledDepartureTime = scheduledDepartureTime - } - - /** Scheduled track information of the arriving transit vehicle. */ - fun scheduledTrack(scheduledTrack: String) = - scheduledTrack(JsonField.of(scheduledTrack)) - - /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") - @ExcludeMissing - fun scheduledTrack(scheduledTrack: JsonField) = apply { - this.scheduledTrack = scheduledTrack - } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this arrival. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - /** Current status of the arrival. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status of the arrival. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - fun stopSequence(stopSequence: Long) = stopSequence(JsonField.of(stopSequence)) - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - @JsonProperty("stopSequence") - @ExcludeMissing - fun stopSequence(stopSequence: JsonField) = apply { - this.stopSequence = stopSequence - } - - /** Total number of stops visited on the trip for this arrival. */ - fun totalStopsInTrip(totalStopsInTrip: Long) = - totalStopsInTrip(JsonField.of(totalStopsInTrip)) - - /** Total number of stops visited on the trip for this arrival. */ - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { - this.totalStopsInTrip = totalStopsInTrip - } - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") - @ExcludeMissing - fun tripStatus(tripStatus: JsonField) = apply { - this.tripStatus = tripStatus - } - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - actualTrack, - arrivalEnabled, - blockTripSequence, - departureEnabled, - distanceFromStop, - frequency, - historicalOccupancy, - lastUpdateTime, - numberOfStopsAway, - occupancyStatus, - predicted, - predictedArrivalInterval, - predictedArrivalTime, - predictedDepartureInterval, - predictedDepartureTime, - predictedOccupancy, - routeId, - routeLongName, - routeShortName, - scheduledArrivalInterval, - scheduledArrivalTime, - scheduledDepartureInterval, - scheduledDepartureTime, - scheduledTrack, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - stopId, - stopSequence, - totalStopsInTrip, - tripHeadsign, - tripId, - tripStatus, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonDeserialize(builder = TripStatus.Builder::class) - @NoAutoDetect - class TripStatus - private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount() = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripStatus = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() - private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() - private var lastKnownLocation: JsonField = JsonMissing.of() - private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var nextStop: JsonField = JsonMissing.of() - private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() - private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tripStatus: TripStatus) = apply { - this.activeTripId = tripStatus.activeTripId - this.blockTripSequence = tripStatus.blockTripSequence - this.closestStop = tripStatus.closestStop - this.closestStopTimeOffset = tripStatus.closestStopTimeOffset - this.distanceAlongTrip = tripStatus.distanceAlongTrip - this.frequency = tripStatus.frequency - this.lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - this.lastKnownLocation = tripStatus.lastKnownLocation - this.lastKnownOrientation = tripStatus.lastKnownOrientation - this.lastLocationUpdateTime = tripStatus.lastLocationUpdateTime - this.lastUpdateTime = tripStatus.lastUpdateTime - this.nextStop = tripStatus.nextStop - this.nextStopTimeOffset = tripStatus.nextStopTimeOffset - this.occupancyCapacity = tripStatus.occupancyCapacity - this.occupancyCount = tripStatus.occupancyCount - this.occupancyStatus = tripStatus.occupancyStatus - this.orientation = tripStatus.orientation - this.phase = tripStatus.phase - this.position = tripStatus.position - this.predicted = tripStatus.predicted - this.scheduleDeviation = tripStatus.scheduleDeviation - this.scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip - this.serviceDate = tripStatus.serviceDate - this.situationIds = tripStatus.situationIds - this.status = tripStatus.status - this.totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip - this.vehicleId = tripStatus.vehicleId - additionalProperties(tripStatus.additionalProperties) - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun activeTripId(activeTripId: JsonField) = apply { - this.activeTripId = activeTripId - } - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun closestStop(closestStop: JsonField) = apply { - this.closestStop = closestStop - } - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = - lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = - apply { - this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip - } - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun lastKnownLocation(lastKnownLocation: JsonField) = apply { - this.lastKnownLocation = lastKnownLocation - } - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: Double) = - lastKnownOrientation(JsonField.of(lastKnownOrientation)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: Long) = - nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing - fun phase(phase: JsonField) = apply { this.phase = phase } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - fun scheduleDeviation(scheduleDeviation: Long) = - scheduleDeviation(JsonField.of(scheduleDeviation)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun scheduleDeviation(scheduleDeviation: JsonField) = apply { - this.scheduleDeviation = scheduleDeviation - } - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { - this.totalDistanceAlongTrip = totalDistanceAlongTrip - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TripStatus = - TripStatus( - activeTripId, - blockTripSequence, - closestStop, - closestStopTimeOffset, - distanceAlongTrip, - frequency, - lastKnownDistanceAlongTrip, - lastKnownLocation, - lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, - nextStop, - nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, - orientation, - phase, - position, - predicted, - scheduleDeviation, - scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) - @NoAutoDetect - class LastKnownLocation - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) - } - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) - @NoAutoDetect - class Position - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) - } - - /** Latitude of the current position of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the current position of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripStatus && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.actualTrack == other.actualTrack && this.arrivalEnabled == other.arrivalEnabled && this.blockTripSequence == other.blockTripSequence && this.departureEnabled == other.departureEnabled && this.distanceFromStop == other.distanceFromStop && this.frequency == other.frequency && this.historicalOccupancy == other.historicalOccupancy && this.lastUpdateTime == other.lastUpdateTime && this.numberOfStopsAway == other.numberOfStopsAway && this.occupancyStatus == other.occupancyStatus && this.predicted == other.predicted && this.predictedArrivalInterval == other.predictedArrivalInterval && this.predictedArrivalTime == other.predictedArrivalTime && this.predictedDepartureInterval == other.predictedDepartureInterval && this.predictedDepartureTime == other.predictedDepartureTime && this.predictedOccupancy == other.predictedOccupancy && this.routeId == other.routeId && this.routeLongName == other.routeLongName && this.routeShortName == other.routeShortName && this.scheduledArrivalInterval == other.scheduledArrivalInterval && this.scheduledArrivalTime == other.scheduledArrivalTime && this.scheduledDepartureInterval == other.scheduledDepartureInterval && this.scheduledDepartureTime == other.scheduledDepartureTime && this.scheduledTrack == other.scheduledTrack && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.stopId == other.stopId && this.stopSequence == other.stopSequence && this.totalStopsInTrip == other.totalStopsInTrip && this.tripHeadsign == other.tripHeadsign && this.tripId == other.tripId && this.tripStatus == other.tripStatus && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(actualTrack, arrivalEnabled, blockTripSequence, departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, predictedArrivalTime, predictedDepartureInterval, predictedDepartureTime, predictedOccupancy, routeId, routeLongName, routeShortName, scheduledArrivalInterval, scheduledArrivalTime, scheduledDepartureInterval, scheduledDepartureTime, scheduledTrack, serviceDate, situationIds, status, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, tripStatus, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{actualTrack=$actualTrack, arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, numberOfStopsAway=$numberOfStopsAway, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedArrivalTime=$predictedArrivalTime, predictedDepartureInterval=$predictedDepartureInterval, predictedDepartureTime=$predictedDepartureTime, predictedOccupancy=$predictedOccupancy, routeId=$routeId, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledDepartureTime=$scheduledDepartureTime, scheduledTrack=$scheduledTrack, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, tripStatus=$tripStatus, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ArrivalAndDepartureRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ArrivalAndDepartureRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt deleted file mode 100644 index 58536ee..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class BlockRetrieveParams -constructor( - private val blockId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun blockId(): String = blockId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> blockId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BlockRetrieveParams && this.blockId == other.blockId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(blockId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "BlockRetrieveParams{blockId=$blockId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var blockId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(blockRetrieveParams: BlockRetrieveParams) = apply { - this.blockId = blockRetrieveParams.blockId - additionalHeaders(blockRetrieveParams.additionalHeaders) - additionalQueryParams(blockRetrieveParams.additionalQueryParams) - } - - fun blockId(blockId: String) = apply { this.blockId = blockId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): BlockRetrieveParams = - BlockRetrieveParams( - checkNotNull(blockId) { "`blockId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt deleted file mode 100644 index fc59f55..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt +++ /dev/null @@ -1,1021 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = BlockRetrieveResponse.Builder::class) -@NoAutoDetect -class BlockRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): BlockRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(blockRetrieveResponse: BlockRetrieveResponse) = apply { - this.code = blockRetrieveResponse.code - this.currentTime = blockRetrieveResponse.currentTime - this.text = blockRetrieveResponse.text - this.version = blockRetrieveResponse.version - this.data = blockRetrieveResponse.data - additionalProperties(blockRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): BlockRetrieveResponse = - BlockRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val id: JsonField, - private val configurations: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun configurations(): List = configurations.getRequired("configurations") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("configurations") @ExcludeMissing fun _configurations() = configurations - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - id() - configurations().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var configurations: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.id = entry.id - this.configurations = entry.configurations - additionalProperties(entry.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun configurations(configurations: List) = - configurations(JsonField.of(configurations)) - - @JsonProperty("configurations") - @ExcludeMissing - fun configurations(configurations: JsonField>) = apply { - this.configurations = configurations - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - id, - configurations.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Configuration.Builder::class) - @NoAutoDetect - class Configuration - private constructor( - private val activeServiceIds: JsonField>, - private val inactiveServiceIds: JsonField>, - private val trips: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun activeServiceIds(): List = - activeServiceIds.getRequired("activeServiceIds") - - fun inactiveServiceIds(): Optional> = - Optional.ofNullable(inactiveServiceIds.getNullable("inactiveServiceIds")) - - fun trips(): List = trips.getRequired("trips") - - @JsonProperty("activeServiceIds") - @ExcludeMissing - fun _activeServiceIds() = activeServiceIds - - @JsonProperty("inactiveServiceIds") - @ExcludeMissing - fun _inactiveServiceIds() = inactiveServiceIds - - @JsonProperty("trips") @ExcludeMissing fun _trips() = trips - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Configuration = apply { - if (!validated) { - activeServiceIds() - inactiveServiceIds() - trips().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var activeServiceIds: JsonField> = JsonMissing.of() - private var inactiveServiceIds: JsonField> = JsonMissing.of() - private var trips: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(configuration: Configuration) = apply { - this.activeServiceIds = configuration.activeServiceIds - this.inactiveServiceIds = configuration.inactiveServiceIds - this.trips = configuration.trips - additionalProperties(configuration.additionalProperties) - } - - fun activeServiceIds(activeServiceIds: List) = - activeServiceIds(JsonField.of(activeServiceIds)) - - @JsonProperty("activeServiceIds") - @ExcludeMissing - fun activeServiceIds(activeServiceIds: JsonField>) = apply { - this.activeServiceIds = activeServiceIds - } - - fun inactiveServiceIds(inactiveServiceIds: List) = - inactiveServiceIds(JsonField.of(inactiveServiceIds)) - - @JsonProperty("inactiveServiceIds") - @ExcludeMissing - fun inactiveServiceIds(inactiveServiceIds: JsonField>) = apply { - this.inactiveServiceIds = inactiveServiceIds - } - - fun trips(trips: List) = trips(JsonField.of(trips)) - - @JsonProperty("trips") - @ExcludeMissing - fun trips(trips: JsonField>) = apply { this.trips = trips } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Configuration = - Configuration( - activeServiceIds.map { it.toImmutable() }, - inactiveServiceIds.map { it.toImmutable() }, - trips.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Trip.Builder::class) - @NoAutoDetect - class Trip - private constructor( - private val tripId: JsonField, - private val distanceAlongBlock: JsonField, - private val accumulatedSlackTime: JsonField, - private val blockStopTimes: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun tripId(): String = tripId.getRequired("tripId") - - fun distanceAlongBlock(): Double = - distanceAlongBlock.getRequired("distanceAlongBlock") - - fun accumulatedSlackTime(): Double = - accumulatedSlackTime.getRequired("accumulatedSlackTime") - - fun blockStopTimes(): List = - blockStopTimes.getRequired("blockStopTimes") - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - fun _distanceAlongBlock() = distanceAlongBlock - - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - fun _accumulatedSlackTime() = accumulatedSlackTime - - @JsonProperty("blockStopTimes") - @ExcludeMissing - fun _blockStopTimes() = blockStopTimes - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Trip = apply { - if (!validated) { - tripId() - distanceAlongBlock() - accumulatedSlackTime() - blockStopTimes().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var tripId: JsonField = JsonMissing.of() - private var distanceAlongBlock: JsonField = JsonMissing.of() - private var accumulatedSlackTime: JsonField = JsonMissing.of() - private var blockStopTimes: JsonField> = - JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(trip: Trip) = apply { - this.tripId = trip.tripId - this.distanceAlongBlock = trip.distanceAlongBlock - this.accumulatedSlackTime = trip.accumulatedSlackTime - this.blockStopTimes = trip.blockStopTimes - additionalProperties(trip.additionalProperties) - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun distanceAlongBlock(distanceAlongBlock: Double) = - distanceAlongBlock(JsonField.of(distanceAlongBlock)) - - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { - this.distanceAlongBlock = distanceAlongBlock - } - - fun accumulatedSlackTime(accumulatedSlackTime: Double) = - accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) - - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = apply { - this.accumulatedSlackTime = accumulatedSlackTime - } - - fun blockStopTimes(blockStopTimes: List) = - blockStopTimes(JsonField.of(blockStopTimes)) - - @JsonProperty("blockStopTimes") - @ExcludeMissing - fun blockStopTimes(blockStopTimes: JsonField>) = apply { - this.blockStopTimes = blockStopTimes - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Trip = - Trip( - tripId, - distanceAlongBlock, - accumulatedSlackTime, - blockStopTimes.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = BlockStopTime.Builder::class) - @NoAutoDetect - class BlockStopTime - private constructor( - private val blockSequence: JsonField, - private val distanceAlongBlock: JsonField, - private val accumulatedSlackTime: JsonField, - private val stopTime: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun blockSequence(): Long = blockSequence.getRequired("blockSequence") - - fun distanceAlongBlock(): Double = - distanceAlongBlock.getRequired("distanceAlongBlock") - - fun accumulatedSlackTime(): Double = - accumulatedSlackTime.getRequired("accumulatedSlackTime") - - fun stopTime(): StopTime = stopTime.getRequired("stopTime") - - @JsonProperty("blockSequence") - @ExcludeMissing - fun _blockSequence() = blockSequence - - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - fun _distanceAlongBlock() = distanceAlongBlock - - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - fun _accumulatedSlackTime() = accumulatedSlackTime - - @JsonProperty("stopTime") @ExcludeMissing fun _stopTime() = stopTime - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): BlockStopTime = apply { - if (!validated) { - blockSequence() - distanceAlongBlock() - accumulatedSlackTime() - stopTime().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var blockSequence: JsonField = JsonMissing.of() - private var distanceAlongBlock: JsonField = JsonMissing.of() - private var accumulatedSlackTime: JsonField = JsonMissing.of() - private var stopTime: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(blockStopTime: BlockStopTime) = apply { - this.blockSequence = blockStopTime.blockSequence - this.distanceAlongBlock = blockStopTime.distanceAlongBlock - this.accumulatedSlackTime = blockStopTime.accumulatedSlackTime - this.stopTime = blockStopTime.stopTime - additionalProperties(blockStopTime.additionalProperties) - } - - fun blockSequence(blockSequence: Long) = - blockSequence(JsonField.of(blockSequence)) - - @JsonProperty("blockSequence") - @ExcludeMissing - fun blockSequence(blockSequence: JsonField) = apply { - this.blockSequence = blockSequence - } - - fun distanceAlongBlock(distanceAlongBlock: Double) = - distanceAlongBlock(JsonField.of(distanceAlongBlock)) - - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { - this.distanceAlongBlock = distanceAlongBlock - } - - fun accumulatedSlackTime(accumulatedSlackTime: Double) = - accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) - - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = - apply { - this.accumulatedSlackTime = accumulatedSlackTime - } - - fun stopTime(stopTime: StopTime) = stopTime(JsonField.of(stopTime)) - - @JsonProperty("stopTime") - @ExcludeMissing - fun stopTime(stopTime: JsonField) = apply { - this.stopTime = stopTime - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): BlockStopTime = - BlockStopTime( - blockSequence, - distanceAlongBlock, - accumulatedSlackTime, - stopTime, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = StopTime.Builder::class) - @NoAutoDetect - class StopTime - private constructor( - private val stopId: JsonField, - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val pickupType: JsonField, - private val dropOffType: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun stopId(): String = stopId.getRequired("stopId") - - fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") - - fun departureTime(): Long = departureTime.getRequired("departureTime") - - fun pickupType(): Optional = - Optional.ofNullable(pickupType.getNullable("pickupType")) - - fun dropOffType(): Optional = - Optional.ofNullable(dropOffType.getNullable("dropOffType")) - - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime() = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime() = departureTime - - @JsonProperty("pickupType") - @ExcludeMissing - fun _pickupType() = pickupType - - @JsonProperty("dropOffType") - @ExcludeMissing - fun _dropOffType() = dropOffType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): StopTime = apply { - if (!validated) { - stopId() - arrivalTime() - departureTime() - pickupType() - dropOffType() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var stopId: JsonField = JsonMissing.of() - private var arrivalTime: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var pickupType: JsonField = JsonMissing.of() - private var dropOffType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopTime: StopTime) = apply { - this.stopId = stopTime.stopId - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.pickupType = stopTime.pickupType - this.dropOffType = stopTime.dropOffType - additionalProperties(stopTime.additionalProperties) - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { - this.stopId = stopId - } - - fun arrivalTime(arrivalTime: Long) = - arrivalTime(JsonField.of(arrivalTime)) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - @JsonProperty("departureTime") - @ExcludeMissing - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun pickupType(pickupType: Long) = - pickupType(JsonField.of(pickupType)) - - @JsonProperty("pickupType") - @ExcludeMissing - fun pickupType(pickupType: JsonField) = apply { - this.pickupType = pickupType - } - - fun dropOffType(dropOffType: Long) = - dropOffType(JsonField.of(dropOffType)) - - @JsonProperty("dropOffType") - @ExcludeMissing - fun dropOffType(dropOffType: JsonField) = apply { - this.dropOffType = dropOffType - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): StopTime = - StopTime( - stopId, - arrivalTime, - departureTime, - pickupType, - dropOffType, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && this.stopId == other.stopId && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.pickupType == other.pickupType && this.dropOffType == other.dropOffType && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(stopId, arrivalTime, departureTime, pickupType, dropOffType, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopTime{stopId=$stopId, arrivalTime=$arrivalTime, departureTime=$departureTime, pickupType=$pickupType, dropOffType=$dropOffType, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BlockStopTime && this.blockSequence == other.blockSequence && this.distanceAlongBlock == other.distanceAlongBlock && this.accumulatedSlackTime == other.accumulatedSlackTime && this.stopTime == other.stopTime && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(blockSequence, distanceAlongBlock, accumulatedSlackTime, stopTime, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "BlockStopTime{blockSequence=$blockSequence, distanceAlongBlock=$distanceAlongBlock, accumulatedSlackTime=$accumulatedSlackTime, stopTime=$stopTime, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Trip && this.tripId == other.tripId && this.distanceAlongBlock == other.distanceAlongBlock && this.accumulatedSlackTime == other.accumulatedSlackTime && this.blockStopTimes == other.blockStopTimes && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(tripId, distanceAlongBlock, accumulatedSlackTime, blockStopTimes, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Trip{tripId=$tripId, distanceAlongBlock=$distanceAlongBlock, accumulatedSlackTime=$accumulatedSlackTime, blockStopTimes=$blockStopTimes, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Configuration && this.activeServiceIds == other.activeServiceIds && this.inactiveServiceIds == other.inactiveServiceIds && this.trips == other.trips && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeServiceIds, inactiveServiceIds, trips, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Configuration{activeServiceIds=$activeServiceIds, inactiveServiceIds=$inactiveServiceIds, trips=$trips, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.id == other.id && this.configurations == other.configurations && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, configurations, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{id=$id, configurations=$configurations, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BlockRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "BlockRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt deleted file mode 100644 index 411d31f..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt +++ /dev/null @@ -1,146 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class ConfigRetrieveParams -constructor( - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ConfigRetrieveParams && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ConfigRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(configRetrieveParams: ConfigRetrieveParams) = apply { - additionalHeaders(configRetrieveParams.additionalHeaders) - additionalQueryParams(configRetrieveParams.additionalQueryParams) - } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): ConfigRetrieveParams = - ConfigRetrieveParams( - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable() - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt deleted file mode 100644 index 22b23c2..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt +++ /dev/null @@ -1,934 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = ConfigRetrieveResponse.Builder::class) -@NoAutoDetect -class ConfigRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ConfigRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(configRetrieveResponse: ConfigRetrieveResponse) = apply { - this.code = configRetrieveResponse.code - this.currentTime = configRetrieveResponse.currentTime - this.text = configRetrieveResponse.text - this.version = configRetrieveResponse.version - this.data = configRetrieveResponse.data - additionalProperties(configRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ConfigRetrieveResponse = - ConfigRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val gitProperties: JsonField, - private val id: JsonField, - private val name: JsonField, - private val serviceDateFrom: JsonField, - private val serviceDateTo: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun gitProperties(): Optional = - Optional.ofNullable(gitProperties.getNullable("gitProperties")) - - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun serviceDateFrom(): Optional = - Optional.ofNullable(serviceDateFrom.getNullable("serviceDateFrom")) - - fun serviceDateTo(): Optional = - Optional.ofNullable(serviceDateTo.getNullable("serviceDateTo")) - - @JsonProperty("gitProperties") @ExcludeMissing fun _gitProperties() = gitProperties - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("serviceDateFrom") - @ExcludeMissing - fun _serviceDateFrom() = serviceDateFrom - - @JsonProperty("serviceDateTo") @ExcludeMissing fun _serviceDateTo() = serviceDateTo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - gitProperties().map { it.validate() } - id() - name() - serviceDateFrom() - serviceDateTo() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var gitProperties: JsonField = JsonMissing.of() - private var id: 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 { - this.gitProperties = entry.gitProperties - this.id = entry.id - this.name = entry.name - this.serviceDateFrom = entry.serviceDateFrom - this.serviceDateTo = entry.serviceDateTo - additionalProperties(entry.additionalProperties) - } - - fun gitProperties(gitProperties: GitProperties) = - gitProperties(JsonField.of(gitProperties)) - - @JsonProperty("gitProperties") - @ExcludeMissing - fun gitProperties(gitProperties: JsonField) = apply { - this.gitProperties = gitProperties - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun serviceDateFrom(serviceDateFrom: String) = - serviceDateFrom(JsonField.of(serviceDateFrom)) - - @JsonProperty("serviceDateFrom") - @ExcludeMissing - fun serviceDateFrom(serviceDateFrom: JsonField) = apply { - this.serviceDateFrom = serviceDateFrom - } - - fun serviceDateTo(serviceDateTo: String) = - serviceDateTo(JsonField.of(serviceDateTo)) - - @JsonProperty("serviceDateTo") - @ExcludeMissing - fun serviceDateTo(serviceDateTo: JsonField) = apply { - this.serviceDateTo = serviceDateTo - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - gitProperties, - id, - name, - serviceDateFrom, - serviceDateTo, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = GitProperties.Builder::class) - @NoAutoDetect - class GitProperties - private constructor( - private val gitBranch: JsonField, - private val gitBuildHost: JsonField, - private val gitBuildTime: JsonField, - private val gitBuildUserEmail: JsonField, - private val gitBuildUserName: JsonField, - private val gitBuildVersion: JsonField, - private val gitClosestTagCommitCount: JsonField, - private val gitClosestTagName: JsonField, - private val gitCommitId: JsonField, - private val gitCommitIdAbbrev: JsonField, - private val gitCommitIdDescribe: JsonField, - private val gitCommitIdDescribeShort: JsonField, - private val gitCommitMessageFull: JsonField, - private val gitCommitMessageShort: JsonField, - private val gitCommitTime: JsonField, - private val gitCommitUserEmail: JsonField, - private val gitCommitUserName: JsonField, - private val gitDirty: JsonField, - private val gitRemoteOriginUrl: JsonField, - private val gitTags: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun gitBranch(): Optional = - Optional.ofNullable(gitBranch.getNullable("git.branch")) - - fun gitBuildHost(): Optional = - Optional.ofNullable(gitBuildHost.getNullable("git.build.host")) - - fun gitBuildTime(): Optional = - Optional.ofNullable(gitBuildTime.getNullable("git.build.time")) - - fun gitBuildUserEmail(): Optional = - Optional.ofNullable(gitBuildUserEmail.getNullable("git.build.user.email")) - - fun gitBuildUserName(): Optional = - Optional.ofNullable(gitBuildUserName.getNullable("git.build.user.name")) - - fun gitBuildVersion(): Optional = - Optional.ofNullable(gitBuildVersion.getNullable("git.build.version")) - - fun gitClosestTagCommitCount(): Optional = - Optional.ofNullable( - gitClosestTagCommitCount.getNullable("git.closest.tag.commit.count") - ) - - fun gitClosestTagName(): Optional = - Optional.ofNullable(gitClosestTagName.getNullable("git.closest.tag.name")) - - fun gitCommitId(): Optional = - Optional.ofNullable(gitCommitId.getNullable("git.commit.id")) - - fun gitCommitIdAbbrev(): Optional = - Optional.ofNullable(gitCommitIdAbbrev.getNullable("git.commit.id.abbrev")) - - fun gitCommitIdDescribe(): Optional = - Optional.ofNullable(gitCommitIdDescribe.getNullable("git.commit.id.describe")) - - fun gitCommitIdDescribeShort(): Optional = - Optional.ofNullable( - gitCommitIdDescribeShort.getNullable("git.commit.id.describe-short") - ) - - fun gitCommitMessageFull(): Optional = - Optional.ofNullable(gitCommitMessageFull.getNullable("git.commit.message.full")) - - fun gitCommitMessageShort(): Optional = - Optional.ofNullable( - gitCommitMessageShort.getNullable("git.commit.message.short") - ) - - fun gitCommitTime(): Optional = - Optional.ofNullable(gitCommitTime.getNullable("git.commit.time")) - - fun gitCommitUserEmail(): Optional = - Optional.ofNullable(gitCommitUserEmail.getNullable("git.commit.user.email")) - - fun gitCommitUserName(): Optional = - Optional.ofNullable(gitCommitUserName.getNullable("git.commit.user.name")) - - fun gitDirty(): Optional = - Optional.ofNullable(gitDirty.getNullable("git.dirty")) - - fun gitRemoteOriginUrl(): Optional = - Optional.ofNullable(gitRemoteOriginUrl.getNullable("git.remote.origin.url")) - - fun gitTags(): Optional = - Optional.ofNullable(gitTags.getNullable("git.tags")) - - @JsonProperty("git.branch") @ExcludeMissing fun _gitBranch() = gitBranch - - @JsonProperty("git.build.host") @ExcludeMissing fun _gitBuildHost() = gitBuildHost - - @JsonProperty("git.build.time") @ExcludeMissing fun _gitBuildTime() = gitBuildTime - - @JsonProperty("git.build.user.email") - @ExcludeMissing - fun _gitBuildUserEmail() = gitBuildUserEmail - - @JsonProperty("git.build.user.name") - @ExcludeMissing - fun _gitBuildUserName() = gitBuildUserName - - @JsonProperty("git.build.version") - @ExcludeMissing - fun _gitBuildVersion() = gitBuildVersion - - @JsonProperty("git.closest.tag.commit.count") - @ExcludeMissing - fun _gitClosestTagCommitCount() = gitClosestTagCommitCount - - @JsonProperty("git.closest.tag.name") - @ExcludeMissing - fun _gitClosestTagName() = gitClosestTagName - - @JsonProperty("git.commit.id") @ExcludeMissing fun _gitCommitId() = gitCommitId - - @JsonProperty("git.commit.id.abbrev") - @ExcludeMissing - fun _gitCommitIdAbbrev() = gitCommitIdAbbrev - - @JsonProperty("git.commit.id.describe") - @ExcludeMissing - fun _gitCommitIdDescribe() = gitCommitIdDescribe - - @JsonProperty("git.commit.id.describe-short") - @ExcludeMissing - fun _gitCommitIdDescribeShort() = gitCommitIdDescribeShort - - @JsonProperty("git.commit.message.full") - @ExcludeMissing - fun _gitCommitMessageFull() = gitCommitMessageFull - - @JsonProperty("git.commit.message.short") - @ExcludeMissing - fun _gitCommitMessageShort() = gitCommitMessageShort - - @JsonProperty("git.commit.time") - @ExcludeMissing - fun _gitCommitTime() = gitCommitTime - - @JsonProperty("git.commit.user.email") - @ExcludeMissing - fun _gitCommitUserEmail() = gitCommitUserEmail - - @JsonProperty("git.commit.user.name") - @ExcludeMissing - fun _gitCommitUserName() = gitCommitUserName - - @JsonProperty("git.dirty") @ExcludeMissing fun _gitDirty() = gitDirty - - @JsonProperty("git.remote.origin.url") - @ExcludeMissing - fun _gitRemoteOriginUrl() = gitRemoteOriginUrl - - @JsonProperty("git.tags") @ExcludeMissing fun _gitTags() = gitTags - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GitProperties = apply { - if (!validated) { - gitBranch() - gitBuildHost() - gitBuildTime() - gitBuildUserEmail() - gitBuildUserName() - gitBuildVersion() - gitClosestTagCommitCount() - gitClosestTagName() - gitCommitId() - gitCommitIdAbbrev() - gitCommitIdDescribe() - gitCommitIdDescribeShort() - gitCommitMessageFull() - gitCommitMessageShort() - gitCommitTime() - gitCommitUserEmail() - gitCommitUserName() - gitDirty() - gitRemoteOriginUrl() - gitTags() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - 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 { - this.gitBranch = gitProperties.gitBranch - this.gitBuildHost = gitProperties.gitBuildHost - this.gitBuildTime = gitProperties.gitBuildTime - this.gitBuildUserEmail = gitProperties.gitBuildUserEmail - this.gitBuildUserName = gitProperties.gitBuildUserName - this.gitBuildVersion = gitProperties.gitBuildVersion - this.gitClosestTagCommitCount = gitProperties.gitClosestTagCommitCount - this.gitClosestTagName = gitProperties.gitClosestTagName - this.gitCommitId = gitProperties.gitCommitId - this.gitCommitIdAbbrev = gitProperties.gitCommitIdAbbrev - this.gitCommitIdDescribe = gitProperties.gitCommitIdDescribe - this.gitCommitIdDescribeShort = gitProperties.gitCommitIdDescribeShort - this.gitCommitMessageFull = gitProperties.gitCommitMessageFull - this.gitCommitMessageShort = gitProperties.gitCommitMessageShort - this.gitCommitTime = gitProperties.gitCommitTime - this.gitCommitUserEmail = gitProperties.gitCommitUserEmail - this.gitCommitUserName = gitProperties.gitCommitUserName - this.gitDirty = gitProperties.gitDirty - this.gitRemoteOriginUrl = gitProperties.gitRemoteOriginUrl - this.gitTags = gitProperties.gitTags - additionalProperties(gitProperties.additionalProperties) - } - - fun gitBranch(gitBranch: String) = gitBranch(JsonField.of(gitBranch)) - - @JsonProperty("git.branch") - @ExcludeMissing - fun gitBranch(gitBranch: JsonField) = apply { - this.gitBranch = gitBranch - } - - fun gitBuildHost(gitBuildHost: String) = - gitBuildHost(JsonField.of(gitBuildHost)) - - @JsonProperty("git.build.host") - @ExcludeMissing - fun gitBuildHost(gitBuildHost: JsonField) = apply { - this.gitBuildHost = gitBuildHost - } - - fun gitBuildTime(gitBuildTime: String) = - gitBuildTime(JsonField.of(gitBuildTime)) - - @JsonProperty("git.build.time") - @ExcludeMissing - fun gitBuildTime(gitBuildTime: JsonField) = apply { - this.gitBuildTime = gitBuildTime - } - - fun gitBuildUserEmail(gitBuildUserEmail: String) = - gitBuildUserEmail(JsonField.of(gitBuildUserEmail)) - - @JsonProperty("git.build.user.email") - @ExcludeMissing - fun gitBuildUserEmail(gitBuildUserEmail: JsonField) = apply { - this.gitBuildUserEmail = gitBuildUserEmail - } - - fun gitBuildUserName(gitBuildUserName: String) = - gitBuildUserName(JsonField.of(gitBuildUserName)) - - @JsonProperty("git.build.user.name") - @ExcludeMissing - fun gitBuildUserName(gitBuildUserName: JsonField) = apply { - this.gitBuildUserName = gitBuildUserName - } - - fun gitBuildVersion(gitBuildVersion: String) = - gitBuildVersion(JsonField.of(gitBuildVersion)) - - @JsonProperty("git.build.version") - @ExcludeMissing - fun gitBuildVersion(gitBuildVersion: JsonField) = apply { - this.gitBuildVersion = gitBuildVersion - } - - fun gitClosestTagCommitCount(gitClosestTagCommitCount: String) = - gitClosestTagCommitCount(JsonField.of(gitClosestTagCommitCount)) - - @JsonProperty("git.closest.tag.commit.count") - @ExcludeMissing - fun gitClosestTagCommitCount(gitClosestTagCommitCount: JsonField) = - apply { - this.gitClosestTagCommitCount = gitClosestTagCommitCount - } - - fun gitClosestTagName(gitClosestTagName: String) = - gitClosestTagName(JsonField.of(gitClosestTagName)) - - @JsonProperty("git.closest.tag.name") - @ExcludeMissing - fun gitClosestTagName(gitClosestTagName: JsonField) = apply { - this.gitClosestTagName = gitClosestTagName - } - - fun gitCommitId(gitCommitId: String) = gitCommitId(JsonField.of(gitCommitId)) - - @JsonProperty("git.commit.id") - @ExcludeMissing - fun gitCommitId(gitCommitId: JsonField) = apply { - this.gitCommitId = gitCommitId - } - - fun gitCommitIdAbbrev(gitCommitIdAbbrev: String) = - gitCommitIdAbbrev(JsonField.of(gitCommitIdAbbrev)) - - @JsonProperty("git.commit.id.abbrev") - @ExcludeMissing - fun gitCommitIdAbbrev(gitCommitIdAbbrev: JsonField) = apply { - this.gitCommitIdAbbrev = gitCommitIdAbbrev - } - - fun gitCommitIdDescribe(gitCommitIdDescribe: String) = - gitCommitIdDescribe(JsonField.of(gitCommitIdDescribe)) - - @JsonProperty("git.commit.id.describe") - @ExcludeMissing - fun gitCommitIdDescribe(gitCommitIdDescribe: JsonField) = apply { - this.gitCommitIdDescribe = gitCommitIdDescribe - } - - fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: String) = - gitCommitIdDescribeShort(JsonField.of(gitCommitIdDescribeShort)) - - @JsonProperty("git.commit.id.describe-short") - @ExcludeMissing - fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: JsonField) = - apply { - this.gitCommitIdDescribeShort = gitCommitIdDescribeShort - } - - fun gitCommitMessageFull(gitCommitMessageFull: String) = - gitCommitMessageFull(JsonField.of(gitCommitMessageFull)) - - @JsonProperty("git.commit.message.full") - @ExcludeMissing - fun gitCommitMessageFull(gitCommitMessageFull: JsonField) = apply { - this.gitCommitMessageFull = gitCommitMessageFull - } - - fun gitCommitMessageShort(gitCommitMessageShort: String) = - gitCommitMessageShort(JsonField.of(gitCommitMessageShort)) - - @JsonProperty("git.commit.message.short") - @ExcludeMissing - fun gitCommitMessageShort(gitCommitMessageShort: JsonField) = apply { - this.gitCommitMessageShort = gitCommitMessageShort - } - - fun gitCommitTime(gitCommitTime: String) = - gitCommitTime(JsonField.of(gitCommitTime)) - - @JsonProperty("git.commit.time") - @ExcludeMissing - fun gitCommitTime(gitCommitTime: JsonField) = apply { - this.gitCommitTime = gitCommitTime - } - - fun gitCommitUserEmail(gitCommitUserEmail: String) = - gitCommitUserEmail(JsonField.of(gitCommitUserEmail)) - - @JsonProperty("git.commit.user.email") - @ExcludeMissing - fun gitCommitUserEmail(gitCommitUserEmail: JsonField) = apply { - this.gitCommitUserEmail = gitCommitUserEmail - } - - fun gitCommitUserName(gitCommitUserName: String) = - gitCommitUserName(JsonField.of(gitCommitUserName)) - - @JsonProperty("git.commit.user.name") - @ExcludeMissing - fun gitCommitUserName(gitCommitUserName: JsonField) = apply { - this.gitCommitUserName = gitCommitUserName - } - - fun gitDirty(gitDirty: String) = gitDirty(JsonField.of(gitDirty)) - - @JsonProperty("git.dirty") - @ExcludeMissing - fun gitDirty(gitDirty: JsonField) = apply { this.gitDirty = gitDirty } - - fun gitRemoteOriginUrl(gitRemoteOriginUrl: String) = - gitRemoteOriginUrl(JsonField.of(gitRemoteOriginUrl)) - - @JsonProperty("git.remote.origin.url") - @ExcludeMissing - fun gitRemoteOriginUrl(gitRemoteOriginUrl: JsonField) = apply { - this.gitRemoteOriginUrl = gitRemoteOriginUrl - } - - fun gitTags(gitTags: String) = gitTags(JsonField.of(gitTags)) - - @JsonProperty("git.tags") - @ExcludeMissing - fun gitTags(gitTags: JsonField) = apply { this.gitTags = gitTags } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitProperties = - GitProperties( - gitBranch, - gitBuildHost, - gitBuildTime, - gitBuildUserEmail, - gitBuildUserName, - gitBuildVersion, - gitClosestTagCommitCount, - gitClosestTagName, - gitCommitId, - gitCommitIdAbbrev, - gitCommitIdDescribe, - gitCommitIdDescribeShort, - gitCommitMessageFull, - gitCommitMessageShort, - gitCommitTime, - gitCommitUserEmail, - gitCommitUserName, - gitDirty, - gitRemoteOriginUrl, - gitTags, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitProperties && this.gitBranch == other.gitBranch && this.gitBuildHost == other.gitBuildHost && this.gitBuildTime == other.gitBuildTime && this.gitBuildUserEmail == other.gitBuildUserEmail && this.gitBuildUserName == other.gitBuildUserName && this.gitBuildVersion == other.gitBuildVersion && this.gitClosestTagCommitCount == other.gitClosestTagCommitCount && this.gitClosestTagName == other.gitClosestTagName && this.gitCommitId == other.gitCommitId && this.gitCommitIdAbbrev == other.gitCommitIdAbbrev && this.gitCommitIdDescribe == other.gitCommitIdDescribe && this.gitCommitIdDescribeShort == other.gitCommitIdDescribeShort && this.gitCommitMessageFull == other.gitCommitMessageFull && this.gitCommitMessageShort == other.gitCommitMessageShort && this.gitCommitTime == other.gitCommitTime && this.gitCommitUserEmail == other.gitCommitUserEmail && this.gitCommitUserName == other.gitCommitUserName && this.gitDirty == other.gitDirty && this.gitRemoteOriginUrl == other.gitRemoteOriginUrl && this.gitTags == other.gitTags && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(gitBranch, gitBuildHost, gitBuildTime, gitBuildUserEmail, gitBuildUserName, gitBuildVersion, gitClosestTagCommitCount, gitClosestTagName, gitCommitId, gitCommitIdAbbrev, gitCommitIdDescribe, gitCommitIdDescribeShort, gitCommitMessageFull, gitCommitMessageShort, gitCommitTime, gitCommitUserEmail, gitCommitUserName, gitDirty, gitRemoteOriginUrl, gitTags, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "GitProperties{gitBranch=$gitBranch, gitBuildHost=$gitBuildHost, gitBuildTime=$gitBuildTime, gitBuildUserEmail=$gitBuildUserEmail, gitBuildUserName=$gitBuildUserName, gitBuildVersion=$gitBuildVersion, gitClosestTagCommitCount=$gitClosestTagCommitCount, gitClosestTagName=$gitClosestTagName, gitCommitId=$gitCommitId, gitCommitIdAbbrev=$gitCommitIdAbbrev, gitCommitIdDescribe=$gitCommitIdDescribe, gitCommitIdDescribeShort=$gitCommitIdDescribeShort, gitCommitMessageFull=$gitCommitMessageFull, gitCommitMessageShort=$gitCommitMessageShort, gitCommitTime=$gitCommitTime, gitCommitUserEmail=$gitCommitUserEmail, gitCommitUserName=$gitCommitUserName, gitDirty=$gitDirty, gitRemoteOriginUrl=$gitRemoteOriginUrl, gitTags=$gitTags, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.gitProperties == other.gitProperties && this.id == other.id && this.name == other.name && this.serviceDateFrom == other.serviceDateFrom && this.serviceDateTo == other.serviceDateTo && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(gitProperties, id, name, serviceDateFrom, serviceDateTo, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{gitProperties=$gitProperties, id=$id, name=$name, serviceDateFrom=$serviceDateFrom, serviceDateTo=$serviceDateTo, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ConfigRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ConfigRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt deleted file mode 100644 index 8cefdb2..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt +++ /dev/null @@ -1,146 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class CurrentTimeRetrieveParams -constructor( - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CurrentTimeRetrieveParams && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "CurrentTimeRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(currentTimeRetrieveParams: CurrentTimeRetrieveParams) = apply { - additionalHeaders(currentTimeRetrieveParams.additionalHeaders) - additionalQueryParams(currentTimeRetrieveParams.additionalQueryParams) - } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): CurrentTimeRetrieveParams = - CurrentTimeRetrieveParams( - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable() - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt deleted file mode 100644 index a1499d6..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt +++ /dev/null @@ -1,393 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = CurrentTimeRetrieveResponse.Builder::class) -@NoAutoDetect -class CurrentTimeRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CurrentTimeRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(currentTimeRetrieveResponse: CurrentTimeRetrieveResponse) = apply { - this.code = currentTimeRetrieveResponse.code - this.currentTime = currentTimeRetrieveResponse.currentTime - this.text = currentTimeRetrieveResponse.text - this.version = currentTimeRetrieveResponse.version - this.data = currentTimeRetrieveResponse.data - additionalProperties(currentTimeRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CurrentTimeRetrieveResponse = - CurrentTimeRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val readableTime: JsonField, - private val time: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun readableTime(): Optional = - Optional.ofNullable(readableTime.getNullable("readableTime")) - - fun time(): Optional = Optional.ofNullable(time.getNullable("time")) - - @JsonProperty("readableTime") @ExcludeMissing fun _readableTime() = readableTime - - @JsonProperty("time") @ExcludeMissing fun _time() = time - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - readableTime() - time() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var readableTime: JsonField = JsonMissing.of() - private var time: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.readableTime = entry.readableTime - this.time = entry.time - additionalProperties(entry.additionalProperties) - } - - fun readableTime(readableTime: String) = readableTime(JsonField.of(readableTime)) - - @JsonProperty("readableTime") - @ExcludeMissing - fun readableTime(readableTime: JsonField) = apply { - this.readableTime = readableTime - } - - fun time(time: Long) = time(JsonField.of(time)) - - @JsonProperty("time") - @ExcludeMissing - fun time(time: JsonField) = apply { this.time = time } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - readableTime, - time, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.readableTime == other.readableTime && this.time == other.time && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(readableTime, time, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{readableTime=$readableTime, time=$time, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CurrentTimeRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "CurrentTimeRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt index 698d6d7..9bbb9ed 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt @@ -6,957 +6,2034 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Enum import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired import org.onebusaway.core.toImmutable import org.onebusaway.errors.OnebusawaySdkInvalidDataException -@JsonDeserialize(builder = References.Builder::class) -@NoAutoDetect class References private constructor( private val agencies: JsonField>, private val routes: JsonField>, private val situations: JsonField>, - private val stopTimes: JsonField>, private val stops: JsonField>, + private val stopTimes: JsonField>, private val trips: JsonField>, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - + @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") - 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 stops(): List = stops.getRequired("stops") - fun trips(): List = trips.getRequired("trips") - - @JsonProperty("agencies") @ExcludeMissing fun _agencies() = agencies - - @JsonProperty("routes") @ExcludeMissing fun _routes() = routes - - @JsonProperty("situations") @ExcludeMissing fun _situations() = situations - - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = 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 stopTimes(): List = stopTimes.getRequired("stopTimes") - @JsonProperty("stops") @ExcludeMissing fun _stops() = 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 trips(): List = trips.getRequired("trips") - @JsonProperty("trips") @ExcludeMissing fun _trips() = trips + /** + * Returns the raw JSON value of [agencies]. + * + * Unlike [agencies], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agencies") @ExcludeMissing fun _agencies(): JsonField> = agencies + + /** + * Returns the raw JSON value of [routes]. + * + * Unlike [routes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routes") @ExcludeMissing fun _routes(): JsonField> = routes + + /** + * Returns the raw JSON value of [situations]. + * + * Unlike [situations], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("situations") + @ExcludeMissing + fun _situations(): JsonField> = situations + + /** + * Returns the raw JSON value of [stops]. + * + * Unlike [stops], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stops") @ExcludeMissing fun _stops(): JsonField> = stops + + /** + * Returns the raw JSON value of [stopTimes]. + * + * Unlike [stopTimes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes + + /** + * Returns the raw JSON value of [trips]. + * + * Unlike [trips], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): References = apply { - if (!validated) { - agencies().forEach { it.validate() } - routes().forEach { it.validate() } - situations().forEach { it.validate() } - stopTimes().forEach { it.validate() } - stops().forEach { it.validate() } - trips().forEach { it.validate() } - validated = true - } - } + 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() } - class Builder { + /** A builder for [References]. */ + class Builder internal constructor() { - private var agencies: JsonField> = JsonMissing.of() - private var routes: JsonField> = JsonMissing.of() - private var situations: JsonField> = JsonMissing.of() - private var stopTimes: JsonField> = JsonMissing.of() - private var stops: JsonField> = JsonMissing.of() - private var trips: JsonField> = JsonMissing.of() + private var agencies: JsonField>? = null + private var routes: JsonField>? = null + private var situations: JsonField>? = null + private var stops: JsonField>? = null + private var stopTimes: JsonField>? = null + private var trips: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(references: References) = apply { - this.agencies = references.agencies - this.routes = references.routes - this.situations = references.situations - this.stopTimes = references.stopTimes - this.stops = references.stops - this.trips = references.trips - additionalProperties(references.additionalProperties) + agencies = references.agencies.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)) - @JsonProperty("agencies") - @ExcludeMissing - fun agencies(agencies: JsonField>) = apply { this.agencies = 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)) - @JsonProperty("routes") - @ExcludeMissing - fun routes(routes: JsonField>) = apply { this.routes = 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)) - @JsonProperty("situations") - @ExcludeMissing + /** + * 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 + this.situations = situations.map { it.toMutableList() } } - fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - - @JsonProperty("stopTimes") - @ExcludeMissing - fun stopTimes(stopTimes: JsonField>) = apply { this.stopTimes = stopTimes } + /** + * 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)) - @JsonProperty("stops") - @ExcludeMissing - fun stops(stops: JsonField>) = apply { this.stops = 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)) - @JsonProperty("trips") - @ExcludeMissing - fun trips(trips: JsonField>) = apply { this.trips = 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * 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( - agencies.map { it.toImmutable() }, - routes.map { it.toImmutable() }, - situations.map { it.toImmutable() }, - stopTimes.map { it.toImmutable() }, - stops.map { it.toImmutable() }, - trips.map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("agencies", agencies).map { it.toImmutable() }, + checkRequired("routes", routes).map { it.toImmutable() }, + checkRequired("situations", situations).map { it.toImmutable() }, + checkRequired("stops", stops).map { it.toImmutable() }, + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("trips", trips).map { it.toImmutable() }, + additionalProperties.toMutableMap(), ) } - @JsonDeserialize(builder = Agency.Builder::class) - @NoAutoDetect + private var validated: Boolean = false + + fun validate(): References = apply { + if (validated) { + return@apply + } + + agencies().forEach { it.validate() } + routes().forEach { it.validate() } + situations().forEach { it.validate() } + stops().forEach { it.validate() } + stopTimes().forEach { it.validate() } + trips().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (agencies.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (routes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (situations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stops.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (trips.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Agency 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 id: JsonField, private val lang: JsonField, - private val name: JsonField, private val phone: JsonField, private val privateService: JsonField, - private val timezone: JsonField, - private val url: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - fun disclaimer(): Optional = - Optional.ofNullable(disclaimer.getNullable("disclaimer")) - - fun email(): Optional = Optional.ofNullable(email.getNullable("email")) - - fun fareUrl(): Optional = Optional.ofNullable(fareUrl.getNullable("fareUrl")) - + @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") - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - fun phone(): Optional = Optional.ofNullable(phone.getNullable("phone")) - - fun privateService(): Optional = - Optional.ofNullable(privateService.getNullable("privateService")) - + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type 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") - @JsonProperty("disclaimer") @ExcludeMissing fun _disclaimer() = disclaimer - - @JsonProperty("email") @ExcludeMissing fun _email() = email - - @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl() = fareUrl - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("phone") @ExcludeMissing fun _phone() = phone - - @JsonProperty("privateService") @ExcludeMissing fun _privateService() = privateService - - @JsonProperty("timezone") @ExcludeMissing fun _timezone() = timezone + /** + * @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 - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Agency = apply { - if (!validated) { - disclaimer() - email() - fareUrl() - id() - lang() - name() - phone() - privateService() - timezone() - url() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Agency]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .timezone() + * .url() + * ``` + */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Agency]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var name: JsonField? = null + private var timezone: JsonField? = null + private var url: JsonField? = null private var disclaimer: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() private var fareUrl: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var lang: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() private var phone: JsonField = JsonMissing.of() private var privateService: JsonField = JsonMissing.of() - private var timezone: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(agency: Agency) = apply { - this.disclaimer = agency.disclaimer - this.email = agency.email - this.fareUrl = agency.fareUrl - this.id = agency.id - this.lang = agency.lang - this.name = agency.name - this.phone = agency.phone - this.privateService = agency.privateService - this.timezone = agency.timezone - this.url = agency.url - additionalProperties(agency.additionalProperties) + 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)) - @JsonProperty("disclaimer") - @ExcludeMissing + /** + * 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)) - @JsonProperty("email") - @ExcludeMissing + /** + * 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)) - @JsonProperty("fareUrl") - @ExcludeMissing + /** + * 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 id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - fun lang(lang: String) = lang(JsonField.of(lang)) - @JsonProperty("lang") - @ExcludeMissing + /** + * 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 name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - fun phone(phone: String) = phone(JsonField.of(phone)) - @JsonProperty("phone") - @ExcludeMissing + /** + * 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)) - @JsonProperty("privateService") - @ExcludeMissing + /** + * 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 timezone(timezone: String) = timezone(JsonField.of(timezone)) - - @JsonProperty("timezone") - @ExcludeMissing - fun timezone(timezone: JsonField) = apply { this.timezone = timezone } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * 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, - id, lang, - name, phone, privateService, - timezone, - url, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): Agency = apply { + if (validated) { + return@apply + } + + id() + name() + timezone() + url() + disclaimer() + email() + fareUrl() + lang() + phone() + privateService() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (disclaimer.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (fareUrl.asKnown().isPresent) 1 else 0) + + (if (lang.asKnown().isPresent) 1 else 0) + + (if (phone.asKnown().isPresent) 1 else 0) + + (if (privateService.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Agency && this.disclaimer == other.disclaimer && this.email == other.email && this.fareUrl == other.fareUrl && this.id == other.id && this.lang == other.lang && this.name == other.name && this.phone == other.phone && this.privateService == other.privateService && this.timezone == other.timezone && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Agency && id == other.id && name == other.name && timezone == other.timezone && url == other.url && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && lang == other.lang && phone == other.phone && privateService == other.privateService && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, timezone, url, disclaimer, email, fareUrl, lang, phone, privateService, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(disclaimer, email, fareUrl, id, lang, name, phone, privateService, timezone, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = - "Agency{disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, id=$id, lang=$lang, name=$name, phone=$phone, privateService=$privateService, timezone=$timezone, url=$url, additionalProperties=$additionalProperties}" + "Agency{id=$id, name=$name, timezone=$timezone, url=$url, disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, lang=$lang, phone=$phone, privateService=$privateService, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Route.Builder::class) - @NoAutoDetect class Route private constructor( + private val id: JsonField, private val agencyId: JsonField, + private val type: JsonField, private val color: JsonField, private val description: JsonField, - private val id: JsonField, private val longName: JsonField, private val nullSafeShortName: JsonField, private val shortName: JsonField, private val textColor: JsonField, - private val type: JsonField, private val url: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - + @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") - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = Optional.ofNullable(textColor.getNullable("textColor")) + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun agencyId(): String = agencyId.getRequired("agencyId") + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun type(): Long = type.getRequired("type") - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId - - @JsonProperty("color") @ExcludeMissing fun _color() = color - - @JsonProperty("description") @ExcludeMissing fun _description() = description - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName - + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + 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() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName + 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 - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Route = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Route]. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Route]. */ + class Builder internal constructor() { - private var agencyId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null private var color: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var longName: JsonField = JsonMissing.of() private var nullSafeShortName: JsonField = JsonMissing.of() private var shortName: JsonField = JsonMissing.of() private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(route: Route) = apply { - this.agencyId = route.agencyId - this.color = route.color - this.description = route.description - this.id = route.id - this.longName = route.longName - this.nullSafeShortName = route.nullSafeShortName - this.shortName = route.shortName - this.textColor = route.textColor - this.type = route.type - this.url = route.url - additionalProperties(route.additionalProperties) + 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)) - @JsonProperty("agencyId") - @ExcludeMissing + /** + * 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)) - @JsonProperty("color") - @ExcludeMissing + /** + * 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)) - @JsonProperty("description") - @ExcludeMissing + /** + * 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 id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - fun longName(longName: String) = longName(JsonField.of(longName)) - @JsonProperty("longName") - @ExcludeMissing + /** + * 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)) - @JsonProperty("nullSafeShortName") - @ExcludeMissing + /** + * 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)) - @JsonProperty("shortName") - @ExcludeMissing + /** + * 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)) - @JsonProperty("textColor") - @ExcludeMissing + /** + * 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 type(type: Long) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * 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( - agencyId, + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), color, description, - id, longName, nullSafeShortName, shortName, textColor, - type, url, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): Route = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Route && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Route && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = - "Route{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" + "Route{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Situation.Builder::class) - @NoAutoDetect class Situation private constructor( private val id: JsonField, private val creationTime: JsonField, - private val reason: JsonField, - private val summary: JsonField, - private val description: JsonField, - private val url: JsonField, private val activeWindows: JsonField>, private val allAffects: JsonField>, + private val consequenceMessage: JsonField, private val consequences: JsonField>, + private val description: JsonField, private val publicationWindows: JsonField>, + private val reason: JsonField, private val severity: JsonField, - private val consequenceMessage: JsonField, - private val additionalProperties: Map, + private val summary: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Unique identifier for the situation. */ + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creationTime") + @ExcludeMissing + creationTime: JsonField = JsonMissing.of(), + @JsonProperty("activeWindows") + @ExcludeMissing + activeWindows: JsonField> = JsonMissing.of(), + @JsonProperty("allAffects") + @ExcludeMissing + allAffects: JsonField> = JsonMissing.of(), + @JsonProperty("consequenceMessage") + @ExcludeMissing + consequenceMessage: JsonField = JsonMissing.of(), + @JsonProperty("consequences") + @ExcludeMissing + consequences: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("publicationWindows") + @ExcludeMissing + publicationWindows: JsonField> = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("severity") + @ExcludeMissing + severity: JsonField = JsonMissing.of(), + @JsonProperty("summary") @ExcludeMissing summary: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + creationTime, + activeWindows, + allAffects, + consequenceMessage, + consequences, + description, + publicationWindows, + reason, + severity, + summary, + url, + mutableMapOf(), + ) + + /** + * Unique identifier for the situation. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Unix timestamp of when this situation was created. */ + /** + * Unix timestamp of when this situation was created. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun creationTime(): Long = creationTime.getRequired("creationTime") - /** Reason for the service alert, taken from TPEG codes. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - fun summary(): Optional = Optional.ofNullable(summary.getNullable("summary")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun activeWindows(): Optional> = - Optional.ofNullable(activeWindows.getNullable("activeWindows")) - - fun allAffects(): Optional> = - Optional.ofNullable(allAffects.getNullable("allAffects")) - - fun consequences(): Optional> = - Optional.ofNullable(consequences.getNullable("consequences")) - - fun publicationWindows(): Optional> = - Optional.ofNullable(publicationWindows.getNullable("publicationWindows")) - - /** Severity of the situation. */ - fun severity(): Optional = Optional.ofNullable(severity.getNullable("severity")) - - /** Message regarding the consequence of the situation. */ + activeWindows.getOptional("activeWindows") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allAffects(): Optional> = allAffects.getOptional("allAffects") + + /** + * Message regarding the consequence of the situation. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun consequenceMessage(): Optional = - Optional.ofNullable(consequenceMessage.getNullable("consequenceMessage")) - - /** Unique identifier for the situation. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** Unix timestamp of when this situation was created. */ - @JsonProperty("creationTime") @ExcludeMissing fun _creationTime() = creationTime - - /** Reason for the service alert, taken from TPEG codes. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason - - @JsonProperty("summary") @ExcludeMissing fun _summary() = summary - - @JsonProperty("description") @ExcludeMissing fun _description() = description - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("activeWindows") @ExcludeMissing fun _activeWindows() = activeWindows - - @JsonProperty("allAffects") @ExcludeMissing fun _allAffects() = allAffects - - @JsonProperty("consequences") @ExcludeMissing fun _consequences() = consequences - - @JsonProperty("publicationWindows") + 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 _publicationWindows() = publicationWindows - - /** Severity of the situation. */ - @JsonProperty("severity") @ExcludeMissing fun _severity() = severity - - /** Message regarding the consequence of the situation. */ + 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() = consequenceMessage - - @JsonAnyGetter + 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 _additionalProperties(): Map = additionalProperties + 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 - fun validate(): Situation = apply { - if (!validated) { - id() - creationTime() - reason() - summary().map { it.validate() } - description().map { it.validate() } - url().map { it.validate() } - activeWindows().map { it.forEach { it.validate() } } - allAffects().map { it.forEach { it.validate() } } - consequences().map { it.forEach { it.validate() } } - publicationWindows().map { it.forEach { it.validate() } } - severity() - consequenceMessage() - validated = true - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } + @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() } - class Builder { + /** A builder for [Situation]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var creationTime: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var creationTime: JsonField? = null + private var activeWindows: JsonField>? = null + private var allAffects: JsonField>? = null + private var consequenceMessage: JsonField = JsonMissing.of() + private var consequences: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var publicationWindows: JsonField>? = null private var reason: JsonField = JsonMissing.of() + private var severity: JsonField = JsonMissing.of() private var summary: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() - private var activeWindows: JsonField> = JsonMissing.of() - private var allAffects: JsonField> = JsonMissing.of() - private var consequences: JsonField> = JsonMissing.of() - private var publicationWindows: JsonField> = JsonMissing.of() - private var severity: JsonField = JsonMissing.of() - private var consequenceMessage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(situation: Situation) = apply { - this.id = situation.id - this.creationTime = situation.creationTime - this.reason = situation.reason - this.summary = situation.summary - this.description = situation.description - this.url = situation.url - this.activeWindows = situation.activeWindows - this.allAffects = situation.allAffects - this.consequences = situation.consequences - this.publicationWindows = situation.publicationWindows - this.severity = situation.severity - this.consequenceMessage = situation.consequenceMessage - additionalProperties(situation.additionalProperties) + id = situation.id + creationTime = situation.creationTime + 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)) - /** Unique identifier for the situation. */ - @JsonProperty("id") - @ExcludeMissing + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun id(id: JsonField) = apply { this.id = id } /** Unix timestamp of when this situation was created. */ fun creationTime(creationTime: Long) = creationTime(JsonField.of(creationTime)) - /** Unix timestamp of when this situation was created. */ - @JsonProperty("creationTime") - @ExcludeMissing + /** + * 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 } - /** Reason for the service alert, taken from TPEG codes. */ - fun reason(reason: Reason) = reason(JsonField.of(reason)) - - /** Reason for the service alert, taken from TPEG codes. */ - @JsonProperty("reason") - @ExcludeMissing - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun summary(summary: Summary) = summary(JsonField.of(summary)) - - @JsonProperty("summary") - @ExcludeMissing - fun summary(summary: JsonField) = apply { this.summary = summary } - - fun description(description: Description) = description(JsonField.of(description)) - - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - fun url(url: Url) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - fun activeWindows(activeWindows: List) = activeWindows(JsonField.of(activeWindows)) - @JsonProperty("activeWindows") - @ExcludeMissing + /** + * 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 + 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)) - @JsonProperty("allAffects") - @ExcludeMissing + /** + * 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 + 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)) - @JsonProperty("consequences") - @ExcludeMissing + /** + * 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 + 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)) - @JsonProperty("publicationWindows") - @ExcludeMissing + /** + * 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 + 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)) - /** Severity of the situation. */ - @JsonProperty("severity") - @ExcludeMissing + /** + * 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 } - /** Message regarding the consequence of the situation. */ - fun consequenceMessage(consequenceMessage: String) = - consequenceMessage(JsonField.of(consequenceMessage)) + fun summary(summary: Summary) = summary(JsonField.of(summary)) - /** Message regarding the consequence of the situation. */ - @JsonProperty("consequenceMessage") - @ExcludeMissing - fun consequenceMessage(consequenceMessage: JsonField) = apply { - this.consequenceMessage = consequenceMessage - } + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * 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( - id, - creationTime, + checkRequired("id", id), + checkRequired("creationTime", creationTime), + (activeWindows ?: JsonMissing.of()).map { it.toImmutable() }, + (allAffects ?: JsonMissing.of()).map { it.toImmutable() }, + consequenceMessage, + (consequences ?: JsonMissing.of()).map { it.toImmutable() }, + description, + (publicationWindows ?: JsonMissing.of()).map { it.toImmutable() }, reason, + severity, summary, - description, url, - activeWindows.map { it.toImmutable() }, - allAffects.map { it.toImmutable() }, - consequences.map { it.toImmutable() }, - publicationWindows.map { it.toImmutable() }, - severity, - consequenceMessage, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } - @JsonDeserialize(builder = ActiveWindow.Builder::class) - @NoAutoDetect + private var validated: Boolean = false + + fun validate(): Situation = apply { + if (validated) { + return@apply + } + + id() + creationTime() + activeWindows().ifPresent { it.forEach { it.validate() } } + allAffects().ifPresent { it.forEach { it.validate() } } + consequenceMessage() + consequences().ifPresent { it.forEach { it.validate() } } + description().ifPresent { it.validate() } + publicationWindows().ifPresent { it.forEach { it.validate() } } + reason().ifPresent { it.validate() } + severity() + summary().ifPresent { it.validate() } + url().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creationTime.asKnown().isPresent) 1 else 0) + + (activeWindows.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (allAffects.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (consequenceMessage.asKnown().isPresent) 1 else 0) + + (consequences.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (description.asKnown().getOrNull()?.validity() ?: 0) + + (publicationWindows.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + (if (severity.asKnown().isPresent) 1 else 0) + + (summary.asKnown().getOrNull()?.validity() ?: 0) + + (url.asKnown().getOrNull()?.validity() ?: 0) + class ActiveWindow private constructor( private val from: JsonField, private val to: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Start time of the active window as a Unix timestamp. */ - fun from(): Optional = Optional.ofNullable(from.getNullable("from")) - - /** End time of the active window as a Unix timestamp. */ - fun to(): Optional = Optional.ofNullable(to.getNullable("to")) - - /** Start time of the active window as a Unix timestamp. */ - @JsonProperty("from") @ExcludeMissing fun _from() = from + @JsonCreator + private constructor( + @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + ) : this(from, to, mutableMapOf()) + + /** + * Start time of the active window as a Unix timestamp. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun from(): Optional = from.getOptional("from") + + /** + * End time of the active window as a Unix timestamp. + * + * @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 - /** End time of the active window as a Unix timestamp. */ - @JsonProperty("to") @ExcludeMissing fun _to() = to + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ActiveWindow = apply { - if (!validated) { - from() - to() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [ActiveWindow]. */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ActiveWindow]. */ + class Builder internal constructor() { private var from: JsonField = JsonMissing.of() private var to: JsonField = JsonMissing.of() @@ -964,35 +2041,42 @@ private constructor( @JvmSynthetic internal fun from(activeWindow: ActiveWindow) = apply { - this.from = activeWindow.from - this.to = activeWindow.to - additionalProperties(activeWindow.additionalProperties) + from = activeWindow.from + to = activeWindow.to + additionalProperties = activeWindow.additionalProperties.toMutableMap() } /** Start time of the active window as a Unix timestamp. */ fun from(from: Long) = from(JsonField.of(from)) - /** Start time of the active window as a Unix timestamp. */ - @JsonProperty("from") - @ExcludeMissing + /** + * Sets [Builder.from] to an arbitrary JSON value. + * + * You should usually call [Builder.from] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun from(from: JsonField) = apply { this.from = from } /** End time of the active window as a Unix timestamp. */ fun to(to: Long) = to(JsonField.of(to)) - /** End time of the active window as a Unix timestamp. */ - @JsonProperty("to") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1000,37 +2084,71 @@ private constructor( this.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.toImmutable(), - ) + ActiveWindow(from, to, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ActiveWindow = apply { + if (validated) { + return@apply + } + + from() + to() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (from.asKnown().isPresent) 1 else 0) + (if (to.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ActiveWindow && this.from == other.from && this.to == other.to && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ActiveWindow && from == other.from && to == other.to && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(from, to, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(from, to, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ActiveWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = AllAffect.Builder::class) - @NoAutoDetect class AllAffect private constructor( private val agencyId: JsonField, @@ -1039,73 +2157,146 @@ private constructor( private val routeId: JsonField, private val stopId: JsonField, private val tripId: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Identifier for the agency. */ - fun agencyId(): Optional = Optional.ofNullable(agencyId.getNullable("agencyId")) - - /** Identifier for the application. */ - fun applicationId(): Optional = - Optional.ofNullable(applicationId.getNullable("applicationId")) - - /** Identifier for the direction. */ - fun directionId(): Optional = - Optional.ofNullable(directionId.getNullable("directionId")) - - /** Identifier for the route. */ - fun routeId(): Optional = Optional.ofNullable(routeId.getNullable("routeId")) - - /** Identifier for the stop. */ - fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) - - /** Identifier for the trip. */ - fun tripId(): Optional = Optional.ofNullable(tripId.getNullable("tripId")) - - /** Identifier for the agency. */ - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId - - /** Identifier for the application. */ - @JsonProperty("applicationId") @ExcludeMissing fun _applicationId() = applicationId - - /** Identifier for the direction. */ - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId - - /** Identifier for the route. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - /** Identifier for the stop. */ - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @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 - /** Identifier for the trip. */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): AllAffect = apply { - if (!validated) { - agencyId() - applicationId() - directionId() - routeId() - stopId() - tripId() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [AllAffect]. */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AllAffect]. */ + class Builder internal constructor() { private var agencyId: JsonField = JsonMissing.of() private var applicationId: JsonField = JsonMissing.of() @@ -1117,30 +2308,38 @@ private constructor( @JvmSynthetic internal fun from(allAffect: AllAffect) = apply { - this.agencyId = allAffect.agencyId - this.applicationId = allAffect.applicationId - this.directionId = allAffect.directionId - this.routeId = allAffect.routeId - this.stopId = allAffect.stopId - this.tripId = allAffect.tripId - additionalProperties(allAffect.additionalProperties) + agencyId = allAffect.agencyId + applicationId = allAffect.applicationId + directionId = allAffect.directionId + routeId = allAffect.routeId + stopId = allAffect.stopId + tripId = allAffect.tripId + additionalProperties = allAffect.additionalProperties.toMutableMap() } /** Identifier for the agency. */ fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - /** Identifier for the agency. */ - @JsonProperty("agencyId") - @ExcludeMissing + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } /** Identifier for the application. */ fun applicationId(applicationId: String) = applicationId(JsonField.of(applicationId)) - /** Identifier for the application. */ - @JsonProperty("applicationId") - @ExcludeMissing + /** + * 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 } @@ -1148,9 +2347,13 @@ private constructor( /** Identifier for the direction. */ fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - /** Identifier for the direction. */ - @JsonProperty("directionId") - @ExcludeMissing + /** + * 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 } @@ -1158,35 +2361,46 @@ private constructor( /** Identifier for the route. */ fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - /** Identifier for the route. */ - @JsonProperty("routeId") - @ExcludeMissing + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun routeId(routeId: JsonField) = apply { this.routeId = routeId } /** Identifier for the stop. */ fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - /** Identifier for the stop. */ - @JsonProperty("stopId") - @ExcludeMissing + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun stopId(stopId: JsonField) = apply { this.stopId = stopId } /** Identifier for the trip. */ fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - /** Identifier for the trip. */ - @JsonProperty("tripId") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1194,6 +2408,19 @@ private constructor( this.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, @@ -1202,76 +2429,139 @@ private constructor( routeId, stopId, tripId, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): AllAffect = apply { + if (validated) { + return@apply + } + + agencyId() + applicationId() + directionId() + routeId() + stopId() + tripId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (agencyId.asKnown().isPresent) 1 else 0) + + (if (applicationId.asKnown().isPresent) 1 else 0) + + (if (directionId.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AllAffect && this.agencyId == other.agencyId && this.applicationId == other.applicationId && this.directionId == other.directionId && this.routeId == other.routeId && this.stopId == other.stopId && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AllAffect && agencyId == other.agencyId && applicationId == other.applicationId && directionId == other.directionId && routeId == other.routeId && stopId == other.stopId && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, applicationId, directionId, routeId, stopId, tripId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, applicationId, directionId, routeId, stopId, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AllAffect{agencyId=$agencyId, applicationId=$applicationId, directionId=$directionId, routeId=$routeId, stopId=$stopId, tripId=$tripId, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Consequence.Builder::class) - @NoAutoDetect class Consequence private constructor( private val condition: JsonField, private val conditionDetails: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Condition of the consequence. */ - fun condition(): Optional = - Optional.ofNullable(condition.getNullable("condition")) - + @JsonCreator + private constructor( + @JsonProperty("condition") + @ExcludeMissing + condition: JsonField = JsonMissing.of(), + @JsonProperty("conditionDetails") + @ExcludeMissing + conditionDetails: JsonField = JsonMissing.of(), + ) : this(condition, conditionDetails, mutableMapOf()) + + /** + * Condition of the consequence. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun condition(): Optional = condition.getOptional("condition") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ fun conditionDetails(): Optional = - Optional.ofNullable(conditionDetails.getNullable("conditionDetails")) - - /** Condition of the consequence. */ - @JsonProperty("condition") @ExcludeMissing fun _condition() = condition - + 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() = conditionDetails + fun _conditionDetails(): JsonField = conditionDetails + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Consequence = apply { - if (!validated) { - condition() - conditionDetails().map { it.validate() } - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [Consequence]. */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Consequence]. */ + class Builder internal constructor() { private var condition: JsonField = JsonMissing.of() private var conditionDetails: JsonField = JsonMissing.of() @@ -1279,36 +2569,44 @@ private constructor( @JvmSynthetic internal fun from(consequence: Consequence) = apply { - this.condition = consequence.condition - this.conditionDetails = consequence.conditionDetails - additionalProperties(consequence.additionalProperties) + condition = consequence.condition + conditionDetails = consequence.conditionDetails + additionalProperties = consequence.additionalProperties.toMutableMap() } /** Condition of the consequence. */ fun condition(condition: String) = condition(JsonField.of(condition)) - /** Condition of the consequence. */ - @JsonProperty("condition") - @ExcludeMissing + /** + * 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)) - @JsonProperty("conditionDetails") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1316,74 +2614,150 @@ private constructor( this.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.toImmutable(), - ) + Consequence(condition, conditionDetails, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Consequence = apply { + if (validated) { + return@apply + } + + condition() + conditionDetails().ifPresent { it.validate() } + validated = true } - @JsonDeserialize(builder = ConditionDetails.Builder::class) - @NoAutoDetect + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (condition.asKnown().isPresent) 1 else 0) + + (conditionDetails.asKnown().getOrNull()?.validity() ?: 0) + class ConditionDetails private constructor( private val diversionPath: JsonField, private val diversionStopIds: JsonField>, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false + @JsonCreator + private constructor( + @JsonProperty("diversionPath") + @ExcludeMissing + diversionPath: JsonField = JsonMissing.of(), + @JsonProperty("diversionStopIds") + @ExcludeMissing + diversionStopIds: JsonField> = JsonMissing.of(), + ) : this(diversionPath, diversionStopIds, mutableMapOf()) + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun diversionPath(): Optional = - Optional.ofNullable(diversionPath.getNullable("diversionPath")) + diversionPath.getOptional("diversionPath") + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun diversionStopIds(): Optional> = - Optional.ofNullable(diversionStopIds.getNullable("diversionStopIds")) - - @JsonProperty("diversionPath") @ExcludeMissing fun _diversionPath() = diversionPath - + 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() = diversionStopIds + fun _diversionStopIds(): JsonField> = diversionStopIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ConditionDetails = apply { - if (!validated) { - diversionPath().map { it.validate() } - diversionStopIds() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [ConditionDetails]. + */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ConditionDetails]. */ + class Builder internal constructor() { private var diversionPath: JsonField = JsonMissing.of() - private var diversionStopIds: JsonField> = JsonMissing.of() + private var diversionStopIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(conditionDetails: ConditionDetails) = apply { - this.diversionPath = conditionDetails.diversionPath - this.diversionStopIds = conditionDetails.diversionStopIds - additionalProperties(conditionDetails.additionalProperties) + diversionPath = conditionDetails.diversionPath + diversionStopIds = + conditionDetails.diversionStopIds.map { it.toMutableList() } + additionalProperties = conditionDetails.additionalProperties.toMutableMap() } fun diversionPath(diversionPath: DiversionPath) = diversionPath(JsonField.of(diversionPath)) - @JsonProperty("diversionPath") - @ExcludeMissing + /** + * 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 } @@ -1391,20 +2765,36 @@ private constructor( fun diversionStopIds(diversionStopIds: List) = diversionStopIds(JsonField.of(diversionStopIds)) - @JsonProperty("diversionStopIds") - @ExcludeMissing + /** + * 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 + 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1412,67 +2802,154 @@ private constructor( this.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.map { it.toImmutable() }, - additionalProperties.toImmutable(), + (diversionStopIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), ) } - @JsonDeserialize(builder = DiversionPath.Builder::class) - @NoAutoDetect + 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 private constructor( private val length: JsonField, private val levels: JsonField, private val points: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Length of the diversion path. */ - fun length(): Optional = Optional.ofNullable(length.getNullable("length")) - - /** Levels of the diversion path. */ - fun levels(): Optional = - Optional.ofNullable(levels.getNullable("levels")) - - /** Points of the diversion path. */ - fun points(): Optional = - Optional.ofNullable(points.getNullable("points")) - - /** Length of the diversion path. */ - @JsonProperty("length") @ExcludeMissing fun _length() = length - - /** Levels of the diversion path. */ - @JsonProperty("levels") @ExcludeMissing fun _levels() = levels + @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 - /** Points of the diversion path. */ - @JsonProperty("points") @ExcludeMissing fun _points() = points + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): DiversionPath = apply { - if (!validated) { - length() - levels() - points() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [DiversionPath]. + */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DiversionPath]. */ + class Builder internal constructor() { private var length: JsonField = JsonMissing.of() private var levels: JsonField = JsonMissing.of() @@ -1482,76 +2959,130 @@ private constructor( @JvmSynthetic internal fun from(diversionPath: DiversionPath) = apply { - this.length = diversionPath.length - this.levels = diversionPath.levels - this.points = diversionPath.points - additionalProperties(diversionPath.additionalProperties) + length = diversionPath.length + levels = diversionPath.levels + points = diversionPath.points + additionalProperties = diversionPath.additionalProperties.toMutableMap() } /** Length of the diversion path. */ fun length(length: Long) = length(JsonField.of(length)) - /** Length of the diversion path. */ - @JsonProperty("length") - @ExcludeMissing + /** + * Sets [Builder.length] to an arbitrary JSON value. + * + * You should usually call [Builder.length] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun length(length: JsonField) = apply { this.length = length } /** Levels of the diversion path. */ fun levels(levels: String) = levels(JsonField.of(levels)) - /** Levels of the diversion path. */ - @JsonProperty("levels") - @ExcludeMissing + /** + * Sets [Builder.levels] to an arbitrary JSON value. + * + * You should usually call [Builder.levels] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun levels(levels: JsonField) = apply { this.levels = levels } /** Points of the diversion path. */ fun points(points: String) = points(JsonField.of(points)) - /** Points of the diversion path. */ - @JsonProperty("points") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DiversionPath]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): DiversionPath = DiversionPath( length, levels, points, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): DiversionPath = apply { + if (validated) { + return@apply + } + + length() + levels() + points() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DiversionPath && this.length == other.length && this.levels == other.levels && this.points == other.points && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DiversionPath && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(length, levels, points, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DiversionPath{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" @@ -1562,17 +3093,14 @@ private constructor( return true } - return /* spotless:off */ other is ConditionDetails && this.diversionPath == other.diversionPath && this.diversionStopIds == other.diversionStopIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ConditionDetails && diversionPath == other.diversionPath && diversionStopIds == other.diversionStopIds && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(diversionPath, diversionStopIds, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(diversionPath, diversionStopIds, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ConditionDetails{diversionPath=$diversionPath, diversionStopIds=$diversionStopIds, additionalProperties=$additionalProperties}" @@ -1583,65 +3111,82 @@ private constructor( return true } - return /* spotless:off */ other is Consequence && this.condition == other.condition && this.conditionDetails == other.conditionDetails && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Consequence && condition == other.condition && conditionDetails == other.conditionDetails && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(condition, conditionDetails, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(condition, conditionDetails, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Consequence{condition=$condition, conditionDetails=$conditionDetails, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Description.Builder::class) - @NoAutoDetect class Description private constructor( private val lang: JsonField, private val value: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Language of the description. */ - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - - /** Longer description of the situation. */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - /** Language of the description. */ - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang + @JsonCreator + private constructor( + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(lang, value, mutableMapOf()) + + /** + * Language of the description. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") + + /** + * Longer description of the situation. + * + * @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 - /** Longer description of the situation. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Description = apply { - if (!validated) { - lang() - value() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [Description]. */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Description]. */ + class Builder internal constructor() { private var lang: JsonField = JsonMissing.of() private var value: JsonField = JsonMissing.of() @@ -1649,35 +3194,42 @@ private constructor( @JvmSynthetic internal fun from(description: Description) = apply { - this.lang = description.lang - this.value = description.value - additionalProperties(description.additionalProperties) + lang = description.lang + value = description.value + additionalProperties = description.additionalProperties.toMutableMap() } /** Language of the description. */ fun lang(lang: String) = lang(JsonField.of(lang)) - /** Language of the description. */ - @JsonProperty("lang") - @ExcludeMissing + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun lang(lang: JsonField) = apply { this.lang = lang } /** Longer description of the situation. */ fun value(value: String) = value(JsonField.of(value)) - /** Longer description of the situation. */ - @JsonProperty("value") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1685,114 +3237,187 @@ private constructor( this.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.toImmutable(), - ) + Description(lang, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Description = apply { + if (validated) { + return@apply + } + + lang() + value() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lang.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Description && this.lang == other.lang && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Description && lang == other.lang && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lang, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Description{lang=$lang, value=$value, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = PublicationWindow.Builder::class) - @NoAutoDetect class PublicationWindow private constructor( private val from: JsonField, private val to: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Start time of the time window as a Unix timestamp. */ + @JsonCreator + private constructor( + @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + ) : this(from, to, mutableMapOf()) + + /** + * Start time of the time window as a Unix timestamp. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun from(): Long = from.getRequired("from") - /** End time of the time window as a Unix timestamp. */ + /** + * End time of the time window as a Unix timestamp. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun to(): Long = to.getRequired("to") - /** Start time of the time window as a Unix timestamp. */ - @JsonProperty("from") @ExcludeMissing fun _from() = from + /** + * 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 - /** End time of the time window as a Unix timestamp. */ - @JsonProperty("to") @ExcludeMissing fun _to() = to + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PublicationWindow = apply { - if (!validated) { - from() - to() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [PublicationWindow]. + * + * The following fields are required: + * ```java + * .from() + * .to() + * ``` + */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PublicationWindow]. */ + class Builder internal constructor() { - private var from: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() + private var from: JsonField? = null + private var to: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(publicationWindow: PublicationWindow) = apply { - this.from = publicationWindow.from - this.to = publicationWindow.to - additionalProperties(publicationWindow.additionalProperties) + from = publicationWindow.from + to = publicationWindow.to + additionalProperties = publicationWindow.additionalProperties.toMutableMap() } /** Start time of the time window as a Unix timestamp. */ fun from(from: Long) = from(JsonField.of(from)) - /** Start time of the time window as a Unix timestamp. */ - @JsonProperty("from") - @ExcludeMissing + /** + * Sets [Builder.from] to an arbitrary JSON value. + * + * You should usually call [Builder.from] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun from(from: JsonField) = apply { this.from = from } /** End time of the time window as a Unix timestamp. */ fun to(to: Long) = to(JsonField.of(to)) - /** End time of the time window as a Unix timestamp. */ - @JsonProperty("to") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1800,70 +3425,112 @@ private constructor( this.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( - from, - to, - additionalProperties.toImmutable(), + checkRequired("from", from), + checkRequired("to", to), + additionalProperties.toMutableMap(), ) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + private var validated: Boolean = false + + fun validate(): PublicationWindow = apply { + if (validated) { + return@apply } - return /* spotless:off */ other is PublicationWindow && this.from == other.from && this.to == other.to && this.additionalProperties == other.additionalProperties /* spotless:on */ + from() + to() + validated = true } - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(from, to, additionalProperties) /* spotless:on */ + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false } - return hashCode - } - - override fun toString() = - "PublicationWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" - } - - class Reason - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns a 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 /* spotless:off */ other is Reason && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is PublicationWindow && from == other.from && to == other.to && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode() = value.hashCode() + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(from, to, additionalProperties) } + /* spotless:on */ - override fun toString() = value.toString() + 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 = Reason(JsonField.of("equipmentReason")) + @JvmField val EQUIPMENT_REASON = of("equipmentReason") - @JvmField val ENVIRONMENT_REASON = Reason(JsonField.of("environmentReason")) + @JvmField val ENVIRONMENT_REASON = of("environmentReason") - @JvmField val PERSONNEL_REASON = Reason(JsonField.of("personnelReason")) + @JvmField val PERSONNEL_REASON = of("personnelReason") - @JvmField val MISCELLANEOUS_REASON = Reason(JsonField.of("miscellaneousReason")) + @JvmField val MISCELLANEOUS_REASON = of("miscellaneousReason") - @JvmField val SECURITY_ALERT = Reason(JsonField.of("securityAlert")) + @JvmField val SECURITY_ALERT = of("securityAlert") @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) } + /** An enum containing [Reason]'s known values. */ enum class Known { EQUIPMENT_REASON, ENVIRONMENT_REASON, @@ -1872,15 +3539,34 @@ private constructor( SECURITY_ALERT, } + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { EQUIPMENT_REASON, ENVIRONMENT_REASON, PERSONNEL_REASON, MISCELLANEOUS_REASON, SECURITY_ALERT, + /** + * An enum member indicating that [Reason] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { EQUIPMENT_REASON -> Value.EQUIPMENT_REASON @@ -1891,6 +3577,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OnebusawaySdkInvalidDataException if this class instance's value is a not a + * known member. + */ fun known(): Known = when (this) { EQUIPMENT_REASON -> Known.EQUIPMENT_REASON @@ -1901,52 +3596,123 @@ private constructor( else -> throw OnebusawaySdkInvalidDataException("Unknown Reason: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OnebusawaySdkInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OnebusawaySdkInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Reason && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - @JsonDeserialize(builder = Summary.Builder::class) - @NoAutoDetect class Summary private constructor( private val lang: JsonField, private val value: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Language of the summary. */ - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - - /** Short summary of the situation. */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - /** Language of the summary. */ - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang + @JsonCreator + private constructor( + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(lang, value, mutableMapOf()) + + /** + * Language of the summary. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") + + /** + * Short summary of the situation. + * + * @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 - /** Short summary of the situation. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Summary = apply { - if (!validated) { - lang() - value() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [Summary]. */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Summary]. */ + class Builder internal constructor() { private var lang: JsonField = JsonMissing.of() private var value: JsonField = JsonMissing.of() @@ -1954,35 +3720,42 @@ private constructor( @JvmSynthetic internal fun from(summary: Summary) = apply { - this.lang = summary.lang - this.value = summary.value - additionalProperties(summary.additionalProperties) + lang = summary.lang + value = summary.value + additionalProperties = summary.additionalProperties.toMutableMap() } /** Language of the summary. */ fun lang(lang: String) = lang(JsonField.of(lang)) - /** Language of the summary. */ - @JsonProperty("lang") - @ExcludeMissing + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun lang(lang: JsonField) = apply { this.lang = lang } /** Short summary of the situation. */ fun value(value: String) = value(JsonField.of(value)) - /** Short summary of the situation. */ - @JsonProperty("value") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1990,78 +3763,133 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Summary = - Summary( - lang, - value, - additionalProperties.toImmutable(), - ) + 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 /* spotless:off */ other is Summary && this.lang == other.lang && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Summary && lang == other.lang && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lang, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Summary{lang=$lang, value=$value, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Url.Builder::class) - @NoAutoDetect class Url private constructor( private val lang: JsonField, private val value: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - /** Language of the URL. */ - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - - /** URL for more information about the situation. */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - /** Language of the URL. */ - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang + @JsonCreator + private constructor( + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(lang, value, mutableMapOf()) + + /** + * Language of the URL. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") + + /** + * URL for more information about the situation. + * + * @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 - /** URL for more information about the situation. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Url = apply { - if (!validated) { - lang() - value() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [Url]. */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Url]. */ + class Builder internal constructor() { private var lang: JsonField = JsonMissing.of() private var value: JsonField = JsonMissing.of() @@ -2069,35 +3897,42 @@ private constructor( @JvmSynthetic internal fun from(url: Url) = apply { - this.lang = url.lang - this.value = url.value - additionalProperties(url.additionalProperties) + lang = url.lang + value = url.value + additionalProperties = url.additionalProperties.toMutableMap() } /** Language of the URL. */ fun lang(lang: String) = lang(JsonField.of(lang)) - /** Language of the URL. */ - @JsonProperty("lang") - @ExcludeMissing + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun lang(lang: JsonField) = apply { this.lang = lang } /** URL for more information about the situation. */ fun value(value: String) = value(JsonField.of(value)) - /** URL for more information about the situation. */ - @JsonProperty("value") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2105,30 +3940,65 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Url = - Url( - lang, - value, - additionalProperties.toImmutable(), - ) + 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 /* spotless:off */ other is Url && this.lang == other.lang && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Url && lang == other.lang && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lang, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Url{lang=$lang, value=$value, additionalProperties=$additionalProperties}" @@ -2139,28 +4009,21 @@ private constructor( return true } - return /* spotless:off */ other is Situation && this.id == other.id && this.creationTime == other.creationTime && this.reason == other.reason && this.summary == other.summary && this.description == other.description && this.url == other.url && this.activeWindows == other.activeWindows && this.allAffects == other.allAffects && this.consequences == other.consequences && this.publicationWindows == other.publicationWindows && this.severity == other.severity && this.consequenceMessage == other.consequenceMessage && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Situation && id == other.id && creationTime == other.creationTime && activeWindows == other.activeWindows && allAffects == other.allAffects && consequenceMessage == other.consequenceMessage && consequences == other.consequences && description == other.description && publicationWindows == other.publicationWindows && reason == other.reason && severity == other.severity && summary == other.summary && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creationTime, activeWindows, allAffects, consequenceMessage, consequences, description, publicationWindows, reason, severity, summary, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, creationTime, reason, summary, description, url, activeWindows, allAffects, consequences, publicationWindows, severity, consequenceMessage, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = - "Situation{id=$id, creationTime=$creationTime, reason=$reason, summary=$summary, description=$description, url=$url, activeWindows=$activeWindows, allAffects=$allAffects, consequences=$consequences, publicationWindows=$publicationWindows, severity=$severity, consequenceMessage=$consequenceMessage, additionalProperties=$additionalProperties}" + "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}" } - @JsonDeserialize(builder = Stop.Builder::class) - @NoAutoDetect class Stop private constructor( - private val code: JsonField, - private val direction: JsonField, private val id: JsonField, private val lat: JsonField, private val locationType: JsonField, @@ -2169,247 +4032,546 @@ private constructor( 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: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - + @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") - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("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 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") - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonProperty("name") @ExcludeMissing fun _name() = 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 name(): String = name.getRequired("name") - @JsonProperty("parent") @ExcludeMissing fun _parent() = 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 parent(): String = parent.getRequired("parent") - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = 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 routeIds(): List = routeIds.getRequired("routeIds") - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds + /** + * @throws OnebusawaySdkInvalidDataException if 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() = wheelchairBoarding + fun _wheelchairBoarding(): JsonField = wheelchairBoarding + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Stop = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Stop]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ @JvmStatic fun builder() = Builder() } - class 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 id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(stop: Stop) = apply { - this.code = stop.code - this.direction = stop.direction - this.id = stop.id - this.lat = stop.lat - this.locationType = stop.locationType - this.lon = stop.lon - this.name = stop.name - this.parent = stop.parent - this.routeIds = stop.routeIds - this.staticRouteIds = stop.staticRouteIds - this.wheelchairBoarding = stop.wheelchairBoarding - additionalProperties(stop.additionalProperties) + 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 code(code: String) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - @JsonProperty("direction") - @ExcludeMissing - fun direction(direction: JsonField) = apply { this.direction = direction } - fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing + /** + * 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)) - @JsonProperty("lat") - @ExcludeMissing + /** + * 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)) - @JsonProperty("locationType") - @ExcludeMissing + /** + * 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)) - @JsonProperty("lon") - @ExcludeMissing + /** + * 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)) - @JsonProperty("name") - @ExcludeMissing + /** + * 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)) - @JsonProperty("parent") - @ExcludeMissing + /** + * 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)) - @JsonProperty("routeIds") - @ExcludeMissing - fun routeIds(routeIds: JsonField>) = apply { this.routeIds = 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)) - @JsonProperty("staticRouteIds") - @ExcludeMissing + /** + * 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 + 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)) - @JsonProperty("wheelchairBoarding") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * 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, - id, - lat, - locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, wheelchairBoarding, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): Stop = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Stop && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Stop && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = - "Stop{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "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}" } - @JsonDeserialize(builder = StopTime.Builder::class) - @NoAutoDetect class StopTime private constructor( private val arrivalTime: JsonField, @@ -2418,68 +4580,151 @@ private constructor( private val historicalOccupancy: JsonField, private val stopHeadsign: JsonField, private val stopId: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") @ExcludeMissing stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) + distanceAlongTrip.getOptional("distanceAlongTrip") + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime - - @JsonProperty("departureTime") @ExcludeMissing fun _departureTime() = departureTime - + 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() = distanceAlongTrip - + 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() = historicalOccupancy + 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 - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = 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 - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [StopTime]. */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTime]. */ + class Builder internal constructor() { private var arrivalTime: JsonField = JsonMissing.of() private var departureTime: JsonField = JsonMissing.of() @@ -2491,25 +4736,35 @@ private constructor( @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() } fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing + /** + * 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)) - @JsonProperty("departureTime") - @ExcludeMissing + /** + * 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 } @@ -2517,8 +4772,13 @@ private constructor( fun distanceAlongTrip(distanceAlongTrip: Double) = distanceAlongTrip(JsonField.of(distanceAlongTrip)) - @JsonProperty("distanceAlongTrip") - @ExcludeMissing + /** + * 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 } @@ -2526,40 +4786,65 @@ private constructor( fun historicalOccupancy(historicalOccupancy: String) = historicalOccupancy(JsonField.of(historicalOccupancy)) - @JsonProperty("historicalOccupancy") - @ExcludeMissing + /** + * 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)) - @JsonProperty("stopHeadsign") - @ExcludeMissing + /** + * 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)) - @JsonProperty("stopId") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): StopTime = StopTime( arrivalTime, @@ -2568,137 +4853,318 @@ private constructor( historicalOccupancy, stopHeadsign, stopId, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Trip.Builder::class) - @NoAutoDetect class Trip private constructor( + private val id: JsonField, + private val routeId: JsonField, + private val serviceId: JsonField, private val blockId: JsonField, private val directionId: JsonField, - private val id: JsonField, private val peakOffpeak: JsonField, - private val routeId: JsonField, private val routeShortName: JsonField, - private val serviceId: JsonField, private val shapeId: JsonField, private val timeZone: JsonField, private val tripHeadsign: JsonField, private val tripShortName: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) - - fun directionId(): Optional = - Optional.ofNullable(directionId.getNullable("directionId")) - + @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") - fun peakOffpeak(): Optional = - Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - + /** + * @throws OnebusawaySdkInvalidDataException if 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") - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun serviceId(): String = serviceId.getRequired("serviceId") - fun shapeId(): Optional = Optional.ofNullable(shapeId.getNullable("shapeId")) - - fun timeZone(): Optional = Optional.ofNullable(timeZone.getNullable("timeZone")) - - fun tripHeadsign(): Optional = - Optional.ofNullable(tripHeadsign.getNullable("tripHeadsign")) - - fun tripShortName(): Optional = - Optional.ofNullable(tripShortName.getNullable("tripShortName")) - - @JsonProperty("blockId") @ExcludeMissing fun _blockId() = blockId - - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("peakOffpeak") @ExcludeMissing fun _peakOffpeak() = peakOffpeak - - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - @JsonProperty("routeShortName") @ExcludeMissing fun _routeShortName() = routeShortName - - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId - - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId() = shapeId - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone - - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign + /** + * @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 - @JsonProperty("tripShortName") @ExcludeMissing fun _tripShortName() = tripShortName + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Trip = apply { - if (!validated) { - blockId() - directionId() - id() - peakOffpeak() - routeId() - routeShortName() - serviceId() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Trip]. + * + * The following fields are required: + * ```java + * .id() + * .routeId() + * .serviceId() + * ``` + */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Trip]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var routeId: JsonField? = null + private var serviceId: JsonField? = null private var blockId: JsonField = JsonMissing.of() private var directionId: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var peakOffpeak: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() private var routeShortName: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() private var shapeId: JsonField = JsonMissing.of() private var timeZone: JsonField = JsonMissing.of() private var tripHeadsign: JsonField = JsonMissing.of() @@ -2707,145 +5173,265 @@ private constructor( @JvmSynthetic internal fun from(trip: Trip) = apply { - this.blockId = trip.blockId - this.directionId = trip.directionId - this.id = trip.id - this.peakOffpeak = trip.peakOffpeak - this.routeId = trip.routeId - this.routeShortName = trip.routeShortName - this.serviceId = trip.serviceId - this.shapeId = trip.shapeId - this.timeZone = trip.timeZone - this.tripHeadsign = trip.tripHeadsign - this.tripShortName = trip.tripShortName - additionalProperties(trip.additionalProperties) + 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)) - @JsonProperty("blockId") - @ExcludeMissing + /** + * 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)) - @JsonProperty("directionId") - @ExcludeMissing + /** + * 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 id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) - @JsonProperty("peakOffpeak") - @ExcludeMissing + /** + * 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 routeId(routeId: String) = routeId(JsonField.of(routeId)) - - @JsonProperty("routeId") - @ExcludeMissing - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - fun routeShortName(routeShortName: String) = routeShortName(JsonField.of(routeShortName)) - @JsonProperty("routeShortName") - @ExcludeMissing + /** + * 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 serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - @JsonProperty("serviceId") - @ExcludeMissing - fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) - @JsonProperty("shapeId") - @ExcludeMissing + /** + * 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)) - @JsonProperty("timeZone") - @ExcludeMissing + /** + * 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)) - @JsonProperty("tripHeadsign") - @ExcludeMissing + /** + * 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)) - @JsonProperty("tripShortName") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * 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, - id, peakOffpeak, - routeId, routeShortName, - serviceId, shapeId, timeZone, tripHeadsign, tripShortName, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): Trip = apply { + if (validated) { + return@apply + } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (if (directionId.asKnown().isPresent) 1 else 0) + + (if (peakOffpeak.asKnown().isPresent) 1 else 0) + + (if (routeShortName.asKnown().isPresent) 1 else 0) + + (if (shapeId.asKnown().isPresent) 1 else 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (if (tripShortName.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Trip && this.blockId == other.blockId && this.directionId == other.directionId && this.id == other.id && this.peakOffpeak == other.peakOffpeak && this.routeId == other.routeId && this.routeShortName == other.routeShortName && this.serviceId == other.serviceId && this.shapeId == other.shapeId && this.timeZone == other.timeZone && this.tripHeadsign == other.tripHeadsign && this.tripShortName == other.tripShortName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Trip && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = - "Trip{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" + "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 { @@ -2853,18 +5439,15 @@ private constructor( return true } - return /* spotless:off */ other is References && this.agencies == other.agencies && this.routes == other.routes && this.situations == other.situations && this.stopTimes == other.stopTimes && this.stops == other.stops && this.trips == other.trips && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is References && agencies == other.agencies && routes == other.routes && situations == other.situations && stops == other.stops && stopTimes == other.stopTimes && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencies, routes, situations, stops, stopTimes, trips, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencies, routes, situations, stopTimes, stops, trips, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = - "References{agencies=$agencies, routes=$routes, situations=$situations, stopTimes=$stopTimes, stops=$stops, trips=$trips, additionalProperties=$additionalProperties}" + "References{agencies=$agencies, routes=$routes, situations=$situations, stops=$stops, stopTimes=$stopTimes, trips=$trips, additionalProperties=$additionalProperties}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt deleted file mode 100644 index 65aa1bc..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt +++ /dev/null @@ -1,301 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonCreator -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.Enum -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.errors.OnebusawaySdkInvalidDataException -import org.onebusaway.models.* - -class ReportProblemWithStopRetrieveParams -constructor( - private val stopId: String, - private val code: Code?, - private val userComment: String?, - private val userLat: Double?, - private val userLocationAccuracy: Double?, - private val userLon: Double?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun stopId(): String = stopId - - fun code(): Optional = Optional.ofNullable(code) - - fun userComment(): Optional = Optional.ofNullable(userComment) - - fun userLat(): Optional = Optional.ofNullable(userLat) - - fun userLocationAccuracy(): Optional = Optional.ofNullable(userLocationAccuracy) - - fun userLon(): Optional = Optional.ofNullable(userLon) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.code?.let { params.put("code", listOf(it.toString())) } - this.userComment?.let { params.put("userComment", listOf(it.toString())) } - this.userLat?.let { params.put("userLat", listOf(it.toString())) } - this.userLocationAccuracy?.let { params.put("userLocationAccuracy", listOf(it.toString())) } - this.userLon?.let { params.put("userLon", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReportProblemWithStopRetrieveParams && this.stopId == other.stopId && this.code == other.code && this.userComment == other.userComment && this.userLat == other.userLat && this.userLocationAccuracy == other.userLocationAccuracy && this.userLon == other.userLon && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, code, userComment, userLat, userLocationAccuracy, userLon, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ReportProblemWithStopRetrieveParams{stopId=$stopId, code=$code, userComment=$userComment, userLat=$userLat, userLocationAccuracy=$userLocationAccuracy, userLon=$userLon, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var stopId: String? = null - private var code: Code? = null - private var userComment: String? = null - private var userLat: Double? = null - private var userLocationAccuracy: Double? = null - private var userLon: Double? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from( - reportProblemWithStopRetrieveParams: ReportProblemWithStopRetrieveParams - ) = apply { - this.stopId = reportProblemWithStopRetrieveParams.stopId - this.code = reportProblemWithStopRetrieveParams.code - this.userComment = reportProblemWithStopRetrieveParams.userComment - this.userLat = reportProblemWithStopRetrieveParams.userLat - this.userLocationAccuracy = reportProblemWithStopRetrieveParams.userLocationAccuracy - this.userLon = reportProblemWithStopRetrieveParams.userLon - additionalHeaders(reportProblemWithStopRetrieveParams.additionalHeaders) - additionalQueryParams(reportProblemWithStopRetrieveParams.additionalQueryParams) - } - - fun stopId(stopId: String) = apply { this.stopId = stopId } - - /** A string code identifying the nature of the problem */ - fun code(code: Code) = apply { this.code = code } - - /** Additional comment text supplied by the user describing the problem */ - fun userComment(userComment: String) = apply { this.userComment = userComment } - - /** The reporting user’s current latitude */ - fun userLat(userLat: Double) = apply { this.userLat = userLat } - - /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(userLocationAccuracy: Double) = apply { - this.userLocationAccuracy = userLocationAccuracy - } - - /** The reporting user’s current longitude */ - fun userLon(userLon: Double) = apply { this.userLon = userLon } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): ReportProblemWithStopRetrieveParams = - ReportProblemWithStopRetrieveParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, - code, - userComment, - userLat, - userLocationAccuracy, - userLon, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } - - class Code - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Code && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val STOP_NAME_WRONG = Code(JsonField.of("stop_name_wrong")) - - @JvmField val STOP_NUMBER_WRONG = Code(JsonField.of("stop_number_wrong")) - - @JvmField val STOP_LOCATION_WRONG = Code(JsonField.of("stop_location_wrong")) - - @JvmField val ROUTE_OR_TRIP_MISSING = Code(JsonField.of("route_or_trip_missing")) - - @JvmField val OTHER = Code(JsonField.of("other")) - - @JvmStatic fun of(value: String) = Code(JsonField.of(value)) - } - - enum class Known { - STOP_NAME_WRONG, - STOP_NUMBER_WRONG, - STOP_LOCATION_WRONG, - ROUTE_OR_TRIP_MISSING, - OTHER, - } - - enum class Value { - STOP_NAME_WRONG, - STOP_NUMBER_WRONG, - STOP_LOCATION_WRONG, - ROUTE_OR_TRIP_MISSING, - OTHER, - _UNKNOWN, - } - - 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 - } - - 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") - } - - fun asString(): String = _value().asStringOrThrow() - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt deleted file mode 100644 index 8767e9b..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt +++ /dev/null @@ -1,360 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonCreator -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.Enum -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.errors.OnebusawaySdkInvalidDataException -import org.onebusaway.models.* - -class ReportProblemWithTripRetrieveParams -constructor( - private val tripId: String, - private val code: Code?, - private val serviceDate: Long?, - private val stopId: String?, - private val userComment: String?, - private val userLat: Double?, - private val userLocationAccuracy: Double?, - private val userLon: Double?, - private val userOnVehicle: Boolean?, - private val userVehicleNumber: String?, - private val vehicleId: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun tripId(): String = tripId - - fun code(): Optional = Optional.ofNullable(code) - - fun serviceDate(): Optional = Optional.ofNullable(serviceDate) - - fun stopId(): Optional = Optional.ofNullable(stopId) - - fun userComment(): Optional = Optional.ofNullable(userComment) - - fun userLat(): Optional = Optional.ofNullable(userLat) - - fun userLocationAccuracy(): Optional = Optional.ofNullable(userLocationAccuracy) - - fun userLon(): Optional = Optional.ofNullable(userLon) - - fun userOnVehicle(): Optional = Optional.ofNullable(userOnVehicle) - - fun userVehicleNumber(): Optional = Optional.ofNullable(userVehicleNumber) - - fun vehicleId(): Optional = Optional.ofNullable(vehicleId) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.code?.let { params.put("code", listOf(it.toString())) } - this.serviceDate?.let { params.put("serviceDate", listOf(it.toString())) } - this.stopId?.let { params.put("stopID", listOf(it.toString())) } - this.userComment?.let { params.put("userComment", listOf(it.toString())) } - this.userLat?.let { params.put("userLat", listOf(it.toString())) } - this.userLocationAccuracy?.let { params.put("userLocationAccuracy", listOf(it.toString())) } - this.userLon?.let { params.put("userLon", listOf(it.toString())) } - this.userOnVehicle?.let { params.put("userOnVehicle", listOf(it.toString())) } - this.userVehicleNumber?.let { params.put("userVehicleNumber", listOf(it.toString())) } - this.vehicleId?.let { params.put("vehicleID", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> tripId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReportProblemWithTripRetrieveParams && this.tripId == other.tripId && this.code == other.code && this.serviceDate == other.serviceDate && this.stopId == other.stopId && this.userComment == other.userComment && this.userLat == other.userLat && this.userLocationAccuracy == other.userLocationAccuracy && this.userLon == other.userLon && this.userOnVehicle == other.userOnVehicle && this.userVehicleNumber == other.userVehicleNumber && this.vehicleId == other.vehicleId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(tripId, code, serviceDate, stopId, userComment, userLat, userLocationAccuracy, userLon, userOnVehicle, userVehicleNumber, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ReportProblemWithTripRetrieveParams{tripId=$tripId, code=$code, serviceDate=$serviceDate, stopId=$stopId, userComment=$userComment, userLat=$userLat, userLocationAccuracy=$userLocationAccuracy, userLon=$userLon, userOnVehicle=$userOnVehicle, userVehicleNumber=$userVehicleNumber, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - 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: Double? = null - private var userLocationAccuracy: Double? = null - private var userLon: Double? = null - private var userOnVehicle: Boolean? = null - private var userVehicleNumber: String? = null - private var vehicleId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from( - reportProblemWithTripRetrieveParams: ReportProblemWithTripRetrieveParams - ) = apply { - this.tripId = reportProblemWithTripRetrieveParams.tripId - this.code = reportProblemWithTripRetrieveParams.code - this.serviceDate = reportProblemWithTripRetrieveParams.serviceDate - this.stopId = reportProblemWithTripRetrieveParams.stopId - this.userComment = reportProblemWithTripRetrieveParams.userComment - this.userLat = reportProblemWithTripRetrieveParams.userLat - this.userLocationAccuracy = reportProblemWithTripRetrieveParams.userLocationAccuracy - this.userLon = reportProblemWithTripRetrieveParams.userLon - this.userOnVehicle = reportProblemWithTripRetrieveParams.userOnVehicle - this.userVehicleNumber = reportProblemWithTripRetrieveParams.userVehicleNumber - this.vehicleId = reportProblemWithTripRetrieveParams.vehicleId - additionalHeaders(reportProblemWithTripRetrieveParams.additionalHeaders) - additionalQueryParams(reportProblemWithTripRetrieveParams.additionalQueryParams) - } - - fun tripId(tripId: String) = apply { this.tripId = tripId } - - /** A string code identifying the nature of the problem */ - fun code(code: Code) = apply { this.code = code } - - /** The service date of the trip */ - fun serviceDate(serviceDate: Long) = apply { this.serviceDate = serviceDate } - - /** A stop ID indicating where the user is experiencing the problem */ - fun stopId(stopId: String) = apply { this.stopId = stopId } - - /** Additional comment text supplied by the user describing the problem */ - fun userComment(userComment: String) = apply { this.userComment = userComment } - - /** The reporting user’s current latitude */ - fun userLat(userLat: Double) = apply { this.userLat = userLat } - - /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(userLocationAccuracy: Double) = apply { - this.userLocationAccuracy = userLocationAccuracy - } - - /** The reporting user’s current longitude */ - fun userLon(userLon: Double) = apply { this.userLon = userLon } - - /** Indicator if the user is on the transit vehicle experiencing the problem */ - fun userOnVehicle(userOnVehicle: Boolean) = apply { this.userOnVehicle = userOnVehicle } - - /** The vehicle number, as reported by the user */ - fun userVehicleNumber(userVehicleNumber: String) = apply { - this.userVehicleNumber = userVehicleNumber - } - - /** The vehicle actively serving the trip */ - fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): ReportProblemWithTripRetrieveParams = - ReportProblemWithTripRetrieveParams( - checkNotNull(tripId) { "`tripId` is required but was not set" }, - code, - serviceDate, - stopId, - userComment, - userLat, - userLocationAccuracy, - userLon, - userOnVehicle, - userVehicleNumber, - vehicleId, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } - - class Code - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Code && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val VEHICLE_NEVER_CAME = Code(JsonField.of("vehicle_never_came")) - - @JvmField val VEHICLE_CAME_EARLY = Code(JsonField.of("vehicle_came_early")) - - @JvmField val VEHICLE_CAME_LATE = Code(JsonField.of("vehicle_came_late")) - - @JvmField val WRONG_HEADSIGN = Code(JsonField.of("wrong_headsign")) - - @JvmField - val VEHICLE_DOES_NOT_STOP_HERE = Code(JsonField.of("vehicle_does_not_stop_here")) - - @JvmField val OTHER = Code(JsonField.of("other")) - - @JvmStatic fun of(value: String) = Code(JsonField.of(value)) - } - - enum class Known { - VEHICLE_NEVER_CAME, - VEHICLE_CAME_EARLY, - VEHICLE_CAME_LATE, - WRONG_HEADSIGN, - VEHICLE_DOES_NOT_STOP_HERE, - OTHER, - } - - enum class Value { - VEHICLE_NEVER_CAME, - VEHICLE_CAME_EARLY, - VEHICLE_CAME_LATE, - WRONG_HEADSIGN, - VEHICLE_DOES_NOT_STOP_HERE, - OTHER, - _UNKNOWN, - } - - 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 - } - - 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") - } - - fun asString(): String = _value().asStringOrThrow() - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt index dd7c5c0..2ac9738 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt @@ -4,147 +4,266 @@ package org.onebusaway.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Collections import java.util.Objects import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException -@JsonDeserialize(builder = ResponseWrapper.Builder::class) -@NoAutoDetect class ResponseWrapper private constructor( private val code: JsonField, private val currentTime: JsonField, private val text: JsonField, private val version: JsonField, - private val additionalProperties: Map, + private val additionalProperties: MutableMap, ) { - private var validated: Boolean = false - + @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") - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ResponseWrapper = apply { - if (!validated) { - code() - currentTime() - text() - version() - validated = true - } - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [ResponseWrapper]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ResponseWrapper]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(responseWrapper: ResponseWrapper) = apply { - this.code = responseWrapper.code - this.currentTime = responseWrapper.currentTime - this.text = responseWrapper.text - this.version = responseWrapper.version - additionalProperties(responseWrapper.additionalProperties) + code = responseWrapper.code + currentTime = responseWrapper.currentTime + text = responseWrapper.text + version = responseWrapper.version + additionalProperties = responseWrapper.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing + /** + * 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)) - @JsonProperty("currentTime") - @ExcludeMissing + /** + * 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)) - @JsonProperty("text") - @ExcludeMissing + /** + * 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)) - @JsonProperty("version") - @ExcludeMissing + /** + * 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() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * 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( - code, - currentTime, - text, - version, - additionalProperties.toImmutable(), + 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 /* spotless:off */ other is ResponseWrapper && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseWrapper && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ResponseWrapper{code=$code, currentTime=$currentTime, text=$text, version=$version, additionalProperties=$additionalProperties}" diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt deleted file mode 100644 index c56d127..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class RouteIdsForAgencyListParams -constructor( - private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun agencyId(): String = agencyId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RouteIdsForAgencyListParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "RouteIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(routeIdsForAgencyListParams: RouteIdsForAgencyListParams) = apply { - this.agencyId = routeIdsForAgencyListParams.agencyId - additionalHeaders(routeIdsForAgencyListParams.additionalHeaders) - additionalQueryParams(routeIdsForAgencyListParams.additionalQueryParams) - } - - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): RouteIdsForAgencyListParams = - RouteIdsForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt deleted file mode 100644 index ba35c08..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt +++ /dev/null @@ -1,299 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = RouteIdsForAgencyListResponse.Builder::class) -@NoAutoDetect -class RouteIdsForAgencyListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RouteIdsForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(routeIdsForAgencyListResponse: RouteIdsForAgencyListResponse) = apply { - this.code = routeIdsForAgencyListResponse.code - this.currentTime = routeIdsForAgencyListResponse.currentTime - this.text = routeIdsForAgencyListResponse.text - this.version = routeIdsForAgencyListResponse.version - this.data = routeIdsForAgencyListResponse.data - additionalProperties(routeIdsForAgencyListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RouteIdsForAgencyListResponse = - RouteIdsForAgencyListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - references, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RouteIdsForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "RouteIdsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt deleted file mode 100644 index a37fb4d..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class RouteRetrieveParams -constructor( - private val routeId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun routeId(): String = routeId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> routeId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RouteRetrieveParams && this.routeId == other.routeId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(routeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "RouteRetrieveParams{routeId=$routeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var routeId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(routeRetrieveParams: RouteRetrieveParams) = apply { - this.routeId = routeRetrieveParams.routeId - additionalHeaders(routeRetrieveParams.additionalHeaders) - additionalQueryParams(routeRetrieveParams.additionalQueryParams) - } - - fun routeId(routeId: String) = apply { this.routeId = routeId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): RouteRetrieveParams = - RouteRetrieveParams( - checkNotNull(routeId) { "`routeId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt deleted file mode 100644 index 4b903c4..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt +++ /dev/null @@ -1,521 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = RouteRetrieveResponse.Builder::class) -@NoAutoDetect -class RouteRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RouteRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(routeRetrieveResponse: RouteRetrieveResponse) = apply { - this.code = routeRetrieveResponse.code - this.currentTime = routeRetrieveResponse.currentTime - this.text = routeRetrieveResponse.text - this.version = routeRetrieveResponse.version - this.data = routeRetrieveResponse.data - additionalProperties(routeRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RouteRetrieveResponse = - RouteRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun id(): String = id.getRequired("id") - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = - Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = - Optional.ofNullable(textColor.getNullable("textColor")) - - fun type(): Long = type.getRequired("type") - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId - - @JsonProperty("color") @ExcludeMissing fun _color() = color - - @JsonProperty("description") @ExcludeMissing fun _description() = description - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName - - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var agencyId: JsonField = JsonMissing.of() - private var color: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var longName: JsonField = JsonMissing.of() - private var nullSafeShortName: JsonField = JsonMissing.of() - private var shortName: JsonField = JsonMissing.of() - private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.agencyId = entry.agencyId - this.color = entry.color - this.description = entry.description - this.id = entry.id - this.longName = entry.longName - this.nullSafeShortName = entry.nullSafeShortName - this.shortName = entry.shortName - this.textColor = entry.textColor - this.type = entry.type - this.url = entry.url - additionalProperties(entry.additionalProperties) - } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - @JsonProperty("agencyId") - @ExcludeMissing - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun color(color: String) = color(JsonField.of(color)) - - @JsonProperty("color") - @ExcludeMissing - fun color(color: JsonField) = apply { this.color = color } - - fun description(description: String) = description(JsonField.of(description)) - - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun longName(longName: String) = longName(JsonField.of(longName)) - - @JsonProperty("longName") - @ExcludeMissing - fun longName(longName: JsonField) = apply { this.longName = longName } - - fun nullSafeShortName(nullSafeShortName: String) = - nullSafeShortName(JsonField.of(nullSafeShortName)) - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun nullSafeShortName(nullSafeShortName: JsonField) = apply { - this.nullSafeShortName = nullSafeShortName - } - - fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - - @JsonProperty("shortName") - @ExcludeMissing - fun shortName(shortName: JsonField) = apply { this.shortName = shortName } - - fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - - @JsonProperty("textColor") - @ExcludeMissing - fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - - fun type(type: Long) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - agencyId, - color, - description, - id, - longName, - nullSafeShortName, - shortName, - textColor, - type, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RouteRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "RouteRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt deleted file mode 100644 index 07bf4e9..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class RoutesForAgencyListParams -constructor( - private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun agencyId(): String = agencyId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoutesForAgencyListParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "RoutesForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(routesForAgencyListParams: RoutesForAgencyListParams) = apply { - this.agencyId = routesForAgencyListParams.agencyId - additionalHeaders(routesForAgencyListParams.additionalHeaders) - additionalQueryParams(routesForAgencyListParams.additionalQueryParams) - } - - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): RoutesForAgencyListParams = - RoutesForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt deleted file mode 100644 index 7f3fa67..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt +++ /dev/null @@ -1,538 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = RoutesForAgencyListResponse.Builder::class) -@NoAutoDetect -class RoutesForAgencyListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RoutesForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(routesForAgencyListResponse: RoutesForAgencyListResponse) = apply { - this.code = routesForAgencyListResponse.code - this.currentTime = routesForAgencyListResponse.currentTime - this.text = routesForAgencyListResponse.text - this.version = routesForAgencyListResponse.version - this.data = routesForAgencyListResponse.data - additionalProperties(routesForAgencyListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RoutesForAgencyListResponse = - RoutesForAgencyListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun id(): String = id.getRequired("id") - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = - Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = - Optional.ofNullable(textColor.getNullable("textColor")) - - fun type(): Long = type.getRequired("type") - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId - - @JsonProperty("color") @ExcludeMissing fun _color() = color - - @JsonProperty("description") @ExcludeMissing fun _description() = description - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName - - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var agencyId: JsonField = JsonMissing.of() - private var color: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var longName: JsonField = JsonMissing.of() - private var nullSafeShortName: JsonField = JsonMissing.of() - private var shortName: JsonField = JsonMissing.of() - private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.agencyId = list.agencyId - this.color = list.color - this.description = list.description - this.id = list.id - this.longName = list.longName - this.nullSafeShortName = list.nullSafeShortName - this.shortName = list.shortName - this.textColor = list.textColor - this.type = list.type - this.url = list.url - additionalProperties(list.additionalProperties) - } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - @JsonProperty("agencyId") - @ExcludeMissing - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun color(color: String) = color(JsonField.of(color)) - - @JsonProperty("color") - @ExcludeMissing - fun color(color: JsonField) = apply { this.color = color } - - fun description(description: String) = description(JsonField.of(description)) - - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun longName(longName: String) = longName(JsonField.of(longName)) - - @JsonProperty("longName") - @ExcludeMissing - fun longName(longName: JsonField) = apply { this.longName = longName } - - fun nullSafeShortName(nullSafeShortName: String) = - nullSafeShortName(JsonField.of(nullSafeShortName)) - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun nullSafeShortName(nullSafeShortName: JsonField) = apply { - this.nullSafeShortName = nullSafeShortName - } - - fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - - @JsonProperty("shortName") - @ExcludeMissing - fun shortName(shortName: JsonField) = apply { this.shortName = shortName } - - fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - - @JsonProperty("textColor") - @ExcludeMissing - fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - - fun type(type: Long) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - agencyId, - color, - description, - id, - longName, - nullSafeShortName, - shortName, - textColor, - type, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoutesForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "RoutesForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt deleted file mode 100644 index fde116f..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt +++ /dev/null @@ -1,206 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class RoutesForLocationListParams -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: Map>, - private val additionalQueryParams: Map>, -) { - - 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) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.lat.let { params.put("lat", listOf(it.toString())) } - this.lon.let { params.put("lon", listOf(it.toString())) } - this.latSpan?.let { params.put("latSpan", listOf(it.toString())) } - this.lonSpan?.let { params.put("lonSpan", listOf(it.toString())) } - this.query?.let { params.put("query", listOf(it.toString())) } - this.radius?.let { params.put("radius", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoutesForLocationListParams && this.lat == other.lat && this.lon == other.lon && this.latSpan == other.latSpan && this.lonSpan == other.lonSpan && this.query == other.query && this.radius == other.radius && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(lat, lon, latSpan, lonSpan, query, radius, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "RoutesForLocationListParams{lat=$lat, lon=$lon, latSpan=$latSpan, lonSpan=$lonSpan, query=$query, radius=$radius, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - 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: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(routesForLocationListParams: RoutesForLocationListParams) = apply { - this.lat = routesForLocationListParams.lat - this.lon = routesForLocationListParams.lon - this.latSpan = routesForLocationListParams.latSpan - this.lonSpan = routesForLocationListParams.lonSpan - this.query = routesForLocationListParams.query - this.radius = routesForLocationListParams.radius - additionalHeaders(routesForLocationListParams.additionalHeaders) - additionalQueryParams(routesForLocationListParams.additionalQueryParams) - } - - fun lat(lat: Double) = apply { this.lat = lat } - - fun lon(lon: Double) = apply { this.lon = lon } - - fun latSpan(latSpan: Double) = apply { this.latSpan = latSpan } - - fun lonSpan(lonSpan: Double) = apply { this.lonSpan = lonSpan } - - fun query(query: String) = apply { this.query = query } - - fun radius(radius: Double) = apply { this.radius = radius } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): RoutesForLocationListParams = - RoutesForLocationListParams( - checkNotNull(lat) { "`lat` is required but was not set" }, - checkNotNull(lon) { "`lon` is required but was not set" }, - latSpan, - lonSpan, - query, - radius, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt deleted file mode 100644 index af00a62..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt +++ /dev/null @@ -1,553 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = RoutesForLocationListResponse.Builder::class) -@NoAutoDetect -class RoutesForLocationListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RoutesForLocationListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(routesForLocationListResponse: RoutesForLocationListResponse) = apply { - this.code = routesForLocationListResponse.code - this.currentTime = routesForLocationListResponse.currentTime - this.text = routesForLocationListResponse.text - this.version = routesForLocationListResponse.version - this.data = routesForLocationListResponse.data - additionalProperties(routesForLocationListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RoutesForLocationListResponse = - RoutesForLocationListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val outOfRange: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.outOfRange = data.outOfRange - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - @JsonProperty("outOfRange") - @ExcludeMissing - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - outOfRange, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun id(): String = id.getRequired("id") - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = - Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = - Optional.ofNullable(textColor.getNullable("textColor")) - - fun type(): Long = type.getRequired("type") - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId - - @JsonProperty("color") @ExcludeMissing fun _color() = color - - @JsonProperty("description") @ExcludeMissing fun _description() = description - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName - - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var agencyId: JsonField = JsonMissing.of() - private var color: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var longName: JsonField = JsonMissing.of() - private var nullSafeShortName: JsonField = JsonMissing.of() - private var shortName: JsonField = JsonMissing.of() - private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.agencyId = list.agencyId - this.color = list.color - this.description = list.description - this.id = list.id - this.longName = list.longName - this.nullSafeShortName = list.nullSafeShortName - this.shortName = list.shortName - this.textColor = list.textColor - this.type = list.type - this.url = list.url - additionalProperties(list.additionalProperties) - } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - @JsonProperty("agencyId") - @ExcludeMissing - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun color(color: String) = color(JsonField.of(color)) - - @JsonProperty("color") - @ExcludeMissing - fun color(color: JsonField) = apply { this.color = color } - - fun description(description: String) = description(JsonField.of(description)) - - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun longName(longName: String) = longName(JsonField.of(longName)) - - @JsonProperty("longName") - @ExcludeMissing - fun longName(longName: JsonField) = apply { this.longName = longName } - - fun nullSafeShortName(nullSafeShortName: String) = - nullSafeShortName(JsonField.of(nullSafeShortName)) - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun nullSafeShortName(nullSafeShortName: JsonField) = apply { - this.nullSafeShortName = nullSafeShortName - } - - fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - - @JsonProperty("shortName") - @ExcludeMissing - fun shortName(shortName: JsonField) = apply { this.shortName = shortName } - - fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - - @JsonProperty("textColor") - @ExcludeMissing - fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - - fun type(type: Long) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - agencyId, - color, - description, - id, - longName, - nullSafeShortName, - shortName, - textColor, - type, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.outOfRange == other.outOfRange && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoutesForLocationListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "RoutesForLocationListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt deleted file mode 100644 index 8d835bc..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt +++ /dev/null @@ -1,181 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.time.LocalDate -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class ScheduleForRouteRetrieveParams -constructor( - private val routeId: String, - private val date: LocalDate?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun routeId(): String = routeId - - fun date(): Optional = Optional.ofNullable(date) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.date?.let { params.put("date", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> routeId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleForRouteRetrieveParams && this.routeId == other.routeId && this.date == other.date && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(routeId, date, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ScheduleForRouteRetrieveParams{routeId=$routeId, date=$date, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var routeId: String? = null - private var date: LocalDate? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(scheduleForRouteRetrieveParams: ScheduleForRouteRetrieveParams) = apply { - this.routeId = scheduleForRouteRetrieveParams.routeId - this.date = scheduleForRouteRetrieveParams.date - additionalHeaders(scheduleForRouteRetrieveParams.additionalHeaders) - additionalQueryParams(scheduleForRouteRetrieveParams.additionalQueryParams) - } - - fun routeId(routeId: String) = apply { this.routeId = routeId } - - /** - * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, - * defaults to current date) - */ - fun date(date: LocalDate) = apply { this.date = date } - - fun 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): ScheduleForRouteRetrieveParams = - ScheduleForRouteRetrieveParams( - checkNotNull(routeId) { "`routeId` is required but was not set" }, - date, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt deleted file mode 100644 index 37a37a4..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt +++ /dev/null @@ -1,1472 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = ScheduleForRouteRetrieveResponse.Builder::class) -@NoAutoDetect -class ScheduleForRouteRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ScheduleForRouteRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scheduleForRouteRetrieveResponse: ScheduleForRouteRetrieveResponse) = - apply { - this.code = scheduleForRouteRetrieveResponse.code - this.currentTime = scheduleForRouteRetrieveResponse.currentTime - this.text = scheduleForRouteRetrieveResponse.text - this.version = scheduleForRouteRetrieveResponse.version - this.data = scheduleForRouteRetrieveResponse.data - additionalProperties(scheduleForRouteRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ScheduleForRouteRetrieveResponse = - ScheduleForRouteRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = Data(entry, additionalProperties.toImmutable()) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val routeId: JsonField, - private val scheduleDate: JsonField, - private val serviceIds: JsonField>, - private val stopTripGroupings: JsonField>, - private val stops: JsonField>, - private val trips: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun routeId(): String = routeId.getRequired("routeId") - - fun scheduleDate(): Long = scheduleDate.getRequired("scheduleDate") - - fun serviceIds(): List = serviceIds.getRequired("serviceIds") - - fun stopTripGroupings(): List = - stopTripGroupings.getRequired("stopTripGroupings") - - fun stops(): List = stops.getRequired("stops") - - fun trips(): List = trips.getRequired("trips") - - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - @JsonProperty("scheduleDate") @ExcludeMissing fun _scheduleDate() = scheduleDate - - @JsonProperty("serviceIds") @ExcludeMissing fun _serviceIds() = serviceIds - - @JsonProperty("stopTripGroupings") - @ExcludeMissing - fun _stopTripGroupings() = stopTripGroupings - - @JsonProperty("stops") @ExcludeMissing fun _stops() = stops - - @JsonProperty("trips") @ExcludeMissing fun _trips() = trips - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - routeId() - scheduleDate() - serviceIds() - stopTripGroupings().forEach { it.validate() } - stops().forEach { it.validate() } - trips().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var routeId: JsonField = JsonMissing.of() - private var scheduleDate: JsonField = JsonMissing.of() - private var serviceIds: JsonField> = JsonMissing.of() - private var stopTripGroupings: JsonField> = JsonMissing.of() - private var stops: JsonField> = JsonMissing.of() - private var trips: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.routeId = entry.routeId - this.scheduleDate = entry.scheduleDate - this.serviceIds = entry.serviceIds - this.stopTripGroupings = entry.stopTripGroupings - this.stops = entry.stops - this.trips = entry.trips - additionalProperties(entry.additionalProperties) - } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - @JsonProperty("routeId") - @ExcludeMissing - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun scheduleDate(scheduleDate: Long) = scheduleDate(JsonField.of(scheduleDate)) - - @JsonProperty("scheduleDate") - @ExcludeMissing - fun scheduleDate(scheduleDate: JsonField) = apply { - this.scheduleDate = scheduleDate - } - - fun serviceIds(serviceIds: List) = serviceIds(JsonField.of(serviceIds)) - - @JsonProperty("serviceIds") - @ExcludeMissing - fun serviceIds(serviceIds: JsonField>) = apply { - this.serviceIds = serviceIds - } - - fun stopTripGroupings(stopTripGroupings: List) = - stopTripGroupings(JsonField.of(stopTripGroupings)) - - @JsonProperty("stopTripGroupings") - @ExcludeMissing - fun stopTripGroupings(stopTripGroupings: JsonField>) = - apply { - this.stopTripGroupings = stopTripGroupings - } - - fun stops(stops: List) = stops(JsonField.of(stops)) - - @JsonProperty("stops") - @ExcludeMissing - fun stops(stops: JsonField>) = apply { this.stops = stops } - - fun trips(trips: List) = trips(JsonField.of(trips)) - - @JsonProperty("trips") - @ExcludeMissing - fun trips(trips: JsonField>) = apply { this.trips = trips } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - routeId, - scheduleDate, - serviceIds.map { it.toImmutable() }, - stopTripGroupings.map { it.toImmutable() }, - stops.map { it.toImmutable() }, - trips.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Stop.Builder::class) - @NoAutoDetect - class Stop - private constructor( - private val code: JsonField, - private val direction: JsonField, - private val id: JsonField, - private val lat: JsonField, - private val locationType: JsonField, - private val lon: JsonField, - private val name: JsonField, - private val parent: JsonField, - private val routeIds: JsonField>, - private val staticRouteIds: JsonField>, - private val wheelchairBoarding: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent - - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun _staticRouteIds() = staticRouteIds - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Stop = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = JsonMissing.of() - private var wheelchairBoarding: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stop: Stop) = apply { - this.code = stop.code - this.direction = stop.direction - this.id = stop.id - this.lat = stop.lat - this.locationType = stop.locationType - this.lon = stop.lon - this.name = stop.name - this.parent = stop.parent - this.routeIds = stop.routeIds - this.staticRouteIds = stop.staticRouteIds - this.wheelchairBoarding = stop.wheelchairBoarding - additionalProperties(stop.additionalProperties) - } - - fun code(code: String) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - @JsonProperty("direction") - @ExcludeMissing - fun direction(direction: JsonField) = apply { - this.direction = direction - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - @JsonProperty("locationType") - @ExcludeMissing - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - @JsonProperty("parent") - @ExcludeMissing - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - - @JsonProperty("routeIds") - @ExcludeMissing - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds - } - - fun staticRouteIds(staticRouteIds: List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds - } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { - this.wheelchairBoarding = wheelchairBoarding - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Stop = - Stop( - code, - direction, - id, - lat, - locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, - wheelchairBoarding, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Stop && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Stop{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = StopTripGrouping.Builder::class) - @NoAutoDetect - class StopTripGrouping - private constructor( - private val directionId: JsonField, - private val stopIds: JsonField>, - private val tripHeadsigns: JsonField>, - private val tripIds: JsonField>, - private val tripsWithStopTimes: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun directionId(): String = directionId.getRequired("directionId") - - fun stopIds(): List = stopIds.getRequired("stopIds") - - fun tripHeadsigns(): List = tripHeadsigns.getRequired("tripHeadsigns") - - fun tripIds(): List = tripIds.getRequired("tripIds") - - fun tripsWithStopTimes(): Optional> = - Optional.ofNullable(tripsWithStopTimes.getNullable("tripsWithStopTimes")) - - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId - - @JsonProperty("stopIds") @ExcludeMissing fun _stopIds() = stopIds - - @JsonProperty("tripHeadsigns") @ExcludeMissing fun _tripHeadsigns() = tripHeadsigns - - @JsonProperty("tripIds") @ExcludeMissing fun _tripIds() = tripIds - - @JsonProperty("tripsWithStopTimes") - @ExcludeMissing - fun _tripsWithStopTimes() = tripsWithStopTimes - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopTripGrouping = apply { - if (!validated) { - directionId() - stopIds() - tripHeadsigns() - tripIds() - tripsWithStopTimes().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var directionId: JsonField = JsonMissing.of() - private var stopIds: JsonField> = JsonMissing.of() - private var tripHeadsigns: JsonField> = JsonMissing.of() - private var tripIds: JsonField> = JsonMissing.of() - private var tripsWithStopTimes: JsonField> = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopTripGrouping: StopTripGrouping) = apply { - this.directionId = stopTripGrouping.directionId - this.stopIds = stopTripGrouping.stopIds - this.tripHeadsigns = stopTripGrouping.tripHeadsigns - this.tripIds = stopTripGrouping.tripIds - this.tripsWithStopTimes = stopTripGrouping.tripsWithStopTimes - additionalProperties(stopTripGrouping.additionalProperties) - } - - fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - - @JsonProperty("directionId") - @ExcludeMissing - fun directionId(directionId: JsonField) = apply { - this.directionId = directionId - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - - @JsonProperty("stopIds") - @ExcludeMissing - fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } - - fun tripHeadsigns(tripHeadsigns: List) = - tripHeadsigns(JsonField.of(tripHeadsigns)) - - @JsonProperty("tripHeadsigns") - @ExcludeMissing - fun tripHeadsigns(tripHeadsigns: JsonField>) = apply { - this.tripHeadsigns = tripHeadsigns - } - - fun tripIds(tripIds: List) = tripIds(JsonField.of(tripIds)) - - @JsonProperty("tripIds") - @ExcludeMissing - fun tripIds(tripIds: JsonField>) = apply { this.tripIds = tripIds } - - fun tripsWithStopTimes(tripsWithStopTimes: List) = - tripsWithStopTimes(JsonField.of(tripsWithStopTimes)) - - @JsonProperty("tripsWithStopTimes") - @ExcludeMissing - fun tripsWithStopTimes(tripsWithStopTimes: JsonField>) = - apply { - this.tripsWithStopTimes = tripsWithStopTimes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StopTripGrouping = - StopTripGrouping( - directionId, - stopIds.map { it.toImmutable() }, - tripHeadsigns.map { it.toImmutable() }, - tripIds.map { it.toImmutable() }, - tripsWithStopTimes.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = TripsWithStopTime.Builder::class) - @NoAutoDetect - class TripsWithStopTime - private constructor( - private val tripId: JsonField, - private val stopTimes: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun tripId(): String = tripId.getRequired("tripId") - - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripsWithStopTime = apply { - if (!validated) { - tripId() - stopTimes().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var tripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tripsWithStopTime: TripsWithStopTime) = apply { - this.tripId = tripsWithStopTime.tripId - this.stopTimes = tripsWithStopTime.stopTimes - additionalProperties(tripsWithStopTime.additionalProperties) - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun stopTimes(stopTimes: List) = - stopTimes(JsonField.of(stopTimes)) - - @JsonProperty("stopTimes") - @ExcludeMissing - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): TripsWithStopTime = - TripsWithStopTime( - tripId, - stopTimes.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = StopTime.Builder::class) - @NoAutoDetect - class StopTime - private constructor( - private val arrivalEnabled: JsonField, - private val arrivalTime: JsonField, - private val departureEnabled: JsonField, - private val departureTime: JsonField, - private val serviceId: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") - - fun departureEnabled(): Boolean = - departureEnabled.getRequired("departureEnabled") - - fun departureTime(): Long = departureTime.getRequired("departureTime") - - fun serviceId(): Optional = - Optional.ofNullable(serviceId.getNullable("serviceId")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): String = stopId.getRequired("stopId") - - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun _arrivalEnabled() = arrivalEnabled - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime() = arrivalTime - - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled() = departureEnabled - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime() = departureTime - - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign() = stopHeadsign - - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopTime = apply { - if (!validated) { - arrivalEnabled() - arrivalTime() - departureEnabled() - departureTime() - serviceId() - stopHeadsign() - stopId() - tripId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arrivalEnabled: JsonField = JsonMissing.of() - private var arrivalTime: JsonField = JsonMissing.of() - private var departureEnabled: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() - private var stopHeadsign: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopTime: StopTime) = apply { - this.arrivalEnabled = stopTime.arrivalEnabled - this.arrivalTime = stopTime.arrivalTime - this.departureEnabled = stopTime.departureEnabled - this.departureTime = stopTime.departureTime - this.serviceId = stopTime.serviceId - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - this.tripId = stopTime.tripId - additionalProperties(stopTime.additionalProperties) - } - - fun arrivalEnabled(arrivalEnabled: Boolean) = - arrivalEnabled(JsonField.of(arrivalEnabled)) - - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun arrivalEnabled(arrivalEnabled: JsonField) = apply { - this.arrivalEnabled = arrivalEnabled - } - - fun arrivalTime(arrivalTime: Long) = - arrivalTime(JsonField.of(arrivalTime)) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureEnabled(departureEnabled: Boolean) = - departureEnabled(JsonField.of(departureEnabled)) - - @JsonProperty("departureEnabled") - @ExcludeMissing - fun departureEnabled(departureEnabled: JsonField) = apply { - this.departureEnabled = departureEnabled - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - @JsonProperty("departureTime") - @ExcludeMissing - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - @JsonProperty("serviceId") - @ExcludeMissing - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): StopTime = - StopTime( - arrivalEnabled, - arrivalTime, - departureEnabled, - departureTime, - serviceId, - stopHeadsign, - stopId, - tripId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && this.arrivalEnabled == other.arrivalEnabled && this.arrivalTime == other.arrivalTime && this.departureEnabled == other.departureEnabled && this.departureTime == other.departureTime && this.serviceId == other.serviceId && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, stopHeadsign, stopId, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, stopHeadsign=$stopHeadsign, stopId=$stopId, tripId=$tripId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsWithStopTime && this.tripId == other.tripId && this.stopTimes == other.stopTimes && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(tripId, stopTimes, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripsWithStopTime{tripId=$tripId, stopTimes=$stopTimes, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTripGrouping && this.directionId == other.directionId && this.stopIds == other.stopIds && this.tripHeadsigns == other.tripHeadsigns && this.tripIds == other.tripIds && this.tripsWithStopTimes == other.tripsWithStopTimes && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(directionId, stopIds, tripHeadsigns, tripIds, tripsWithStopTimes, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Trip.Builder::class) - @NoAutoDetect - class Trip - private constructor( - private val blockId: JsonField, - private val directionId: JsonField, - private val id: JsonField, - private val peakOffpeak: JsonField, - private val routeId: JsonField, - private val routeShortName: JsonField, - private val serviceId: JsonField, - private val shapeId: JsonField, - private val timeZone: JsonField, - private val tripHeadsign: JsonField, - private val tripShortName: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun blockId(): Optional = - Optional.ofNullable(blockId.getNullable("blockId")) - - fun directionId(): Optional = - Optional.ofNullable(directionId.getNullable("directionId")) - - fun id(): String = id.getRequired("id") - - fun peakOffpeak(): Optional = - Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - - fun routeId(): String = routeId.getRequired("routeId") - - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - fun serviceId(): String = serviceId.getRequired("serviceId") - - fun shapeId(): Optional = - Optional.ofNullable(shapeId.getNullable("shapeId")) - - fun timeZone(): Optional = - Optional.ofNullable(timeZone.getNullable("timeZone")) - - fun tripHeadsign(): Optional = - Optional.ofNullable(tripHeadsign.getNullable("tripHeadsign")) - - fun tripShortName(): Optional = - Optional.ofNullable(tripShortName.getNullable("tripShortName")) - - @JsonProperty("blockId") @ExcludeMissing fun _blockId() = blockId - - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("peakOffpeak") @ExcludeMissing fun _peakOffpeak() = peakOffpeak - - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - @JsonProperty("routeShortName") - @ExcludeMissing - fun _routeShortName() = routeShortName - - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId - - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId() = shapeId - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone - - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign - - @JsonProperty("tripShortName") @ExcludeMissing fun _tripShortName() = tripShortName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Trip = apply { - if (!validated) { - blockId() - directionId() - id() - peakOffpeak() - routeId() - routeShortName() - serviceId() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var blockId: JsonField = JsonMissing.of() - private var directionId: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var peakOffpeak: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() - private var routeShortName: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() - private var shapeId: JsonField = JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() - private var tripShortName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trip: Trip) = apply { - this.blockId = trip.blockId - this.directionId = trip.directionId - this.id = trip.id - this.peakOffpeak = trip.peakOffpeak - this.routeId = trip.routeId - this.routeShortName = trip.routeShortName - this.serviceId = trip.serviceId - this.shapeId = trip.shapeId - this.timeZone = trip.timeZone - this.tripHeadsign = trip.tripHeadsign - this.tripShortName = trip.tripShortName - additionalProperties(trip.additionalProperties) - } - - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - - @JsonProperty("blockId") - @ExcludeMissing - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - - @JsonProperty("directionId") - @ExcludeMissing - fun directionId(directionId: JsonField) = apply { - this.directionId = directionId - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) - - @JsonProperty("peakOffpeak") - @ExcludeMissing - fun peakOffpeak(peakOffpeak: JsonField) = apply { - this.peakOffpeak = peakOffpeak - } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - @JsonProperty("routeId") - @ExcludeMissing - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun routeShortName(routeShortName: String) = - routeShortName(JsonField.of(routeShortName)) - - @JsonProperty("routeShortName") - @ExcludeMissing - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - @JsonProperty("serviceId") - @ExcludeMissing - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) - - @JsonProperty("shapeId") - @ExcludeMissing - fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - @JsonProperty("timeZone") - @ExcludeMissing - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun tripHeadsign(tripHeadsign: String) = - tripHeadsign(JsonField.of(tripHeadsign)) - - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } - - fun tripShortName(tripShortName: String) = - tripShortName(JsonField.of(tripShortName)) - - @JsonProperty("tripShortName") - @ExcludeMissing - fun tripShortName(tripShortName: JsonField) = apply { - this.tripShortName = tripShortName - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Trip = - Trip( - blockId, - directionId, - id, - peakOffpeak, - routeId, - routeShortName, - serviceId, - shapeId, - timeZone, - tripHeadsign, - tripShortName, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Trip && this.blockId == other.blockId && this.directionId == other.directionId && this.id == other.id && this.peakOffpeak == other.peakOffpeak && this.routeId == other.routeId && this.routeShortName == other.routeShortName && this.serviceId == other.serviceId && this.shapeId == other.shapeId && this.timeZone == other.timeZone && this.tripHeadsign == other.tripHeadsign && this.tripShortName == other.tripShortName && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Trip{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.routeId == other.routeId && this.scheduleDate == other.scheduleDate && this.serviceIds == other.serviceIds && this.stopTripGroupings == other.stopTripGroupings && this.stops == other.stops && this.trips == other.trips && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(routeId, scheduleDate, serviceIds, stopTripGroupings, stops, trips, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stopTripGroupings=$stopTripGroupings, stops=$stops, trips=$trips, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = "Data{entry=$entry, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleForRouteRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ScheduleForRouteRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt deleted file mode 100644 index 6153cb7..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt +++ /dev/null @@ -1,181 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.time.LocalDate -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class ScheduleForStopRetrieveParams -constructor( - private val stopId: String, - private val date: LocalDate?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun stopId(): String = stopId - - fun date(): Optional = Optional.ofNullable(date) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.date?.let { params.put("date", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleForStopRetrieveParams && this.stopId == other.stopId && this.date == other.date && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, date, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ScheduleForStopRetrieveParams{stopId=$stopId, date=$date, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var stopId: String? = null - private var date: LocalDate? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(scheduleForStopRetrieveParams: ScheduleForStopRetrieveParams) = apply { - this.stopId = scheduleForStopRetrieveParams.stopId - this.date = scheduleForStopRetrieveParams.date - additionalHeaders(scheduleForStopRetrieveParams.additionalHeaders) - additionalQueryParams(scheduleForStopRetrieveParams.additionalQueryParams) - } - - fun stopId(stopId: String) = apply { this.stopId = 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(date: LocalDate) = apply { this.date = date } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): ScheduleForStopRetrieveParams = - ScheduleForStopRetrieveParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, - date, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt deleted file mode 100644 index 3dab4f2..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt +++ /dev/null @@ -1,1066 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = ScheduleForStopRetrieveResponse.Builder::class) -@NoAutoDetect -class ScheduleForStopRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ScheduleForStopRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scheduleForStopRetrieveResponse: ScheduleForStopRetrieveResponse) = - apply { - this.code = scheduleForStopRetrieveResponse.code - this.currentTime = scheduleForStopRetrieveResponse.currentTime - this.text = scheduleForStopRetrieveResponse.text - this.version = scheduleForStopRetrieveResponse.version - this.data = scheduleForStopRetrieveResponse.data - additionalProperties(scheduleForStopRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ScheduleForStopRetrieveResponse = - ScheduleForStopRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val date: JsonField, - private val stopId: JsonField, - private val stopRouteSchedules: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun date(): Long = date.getRequired("date") - - fun stopId(): String = stopId.getRequired("stopId") - - fun stopRouteSchedules(): List = - stopRouteSchedules.getRequired("stopRouteSchedules") - - @JsonProperty("date") @ExcludeMissing fun _date() = date - - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - @JsonProperty("stopRouteSchedules") - @ExcludeMissing - fun _stopRouteSchedules() = stopRouteSchedules - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - date() - stopId() - stopRouteSchedules().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var date: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var stopRouteSchedules: JsonField> = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.date = entry.date - this.stopId = entry.stopId - this.stopRouteSchedules = entry.stopRouteSchedules - additionalProperties(entry.additionalProperties) - } - - fun date(date: Long) = date(JsonField.of(date)) - - @JsonProperty("date") - @ExcludeMissing - fun date(date: JsonField) = apply { this.date = date } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun stopRouteSchedules(stopRouteSchedules: List) = - stopRouteSchedules(JsonField.of(stopRouteSchedules)) - - @JsonProperty("stopRouteSchedules") - @ExcludeMissing - fun stopRouteSchedules(stopRouteSchedules: JsonField>) = - apply { - this.stopRouteSchedules = stopRouteSchedules - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - date, - stopId, - stopRouteSchedules.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = StopRouteSchedule.Builder::class) - @NoAutoDetect - class StopRouteSchedule - private constructor( - private val routeId: JsonField, - private val stopRouteDirectionSchedules: - JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun routeId(): String = routeId.getRequired("routeId") - - fun stopRouteDirectionSchedules(): List = - stopRouteDirectionSchedules.getRequired("stopRouteDirectionSchedules") - - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - @JsonProperty("stopRouteDirectionSchedules") - @ExcludeMissing - fun _stopRouteDirectionSchedules() = stopRouteDirectionSchedules - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopRouteSchedule = apply { - if (!validated) { - routeId() - stopRouteDirectionSchedules().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var routeId: JsonField = JsonMissing.of() - private var stopRouteDirectionSchedules: - JsonField> = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopRouteSchedule: StopRouteSchedule) = apply { - this.routeId = stopRouteSchedule.routeId - this.stopRouteDirectionSchedules = - stopRouteSchedule.stopRouteDirectionSchedules - additionalProperties(stopRouteSchedule.additionalProperties) - } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - @JsonProperty("routeId") - @ExcludeMissing - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun stopRouteDirectionSchedules( - stopRouteDirectionSchedules: List - ) = stopRouteDirectionSchedules(JsonField.of(stopRouteDirectionSchedules)) - - @JsonProperty("stopRouteDirectionSchedules") - @ExcludeMissing - fun stopRouteDirectionSchedules( - stopRouteDirectionSchedules: JsonField> - ) = apply { this.stopRouteDirectionSchedules = stopRouteDirectionSchedules } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StopRouteSchedule = - StopRouteSchedule( - routeId, - stopRouteDirectionSchedules.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = StopRouteDirectionSchedule.Builder::class) - @NoAutoDetect - class StopRouteDirectionSchedule - private constructor( - private val scheduleFrequencies: JsonField>, - private val scheduleStopTimes: JsonField>, - private val tripHeadsign: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun scheduleFrequencies(): Optional> = - Optional.ofNullable(scheduleFrequencies.getNullable("scheduleFrequencies")) - - fun scheduleStopTimes(): List = - scheduleStopTimes.getRequired("scheduleStopTimes") - - fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - - @JsonProperty("scheduleFrequencies") - @ExcludeMissing - fun _scheduleFrequencies() = scheduleFrequencies - - @JsonProperty("scheduleStopTimes") - @ExcludeMissing - fun _scheduleStopTimes() = scheduleStopTimes - - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopRouteDirectionSchedule = apply { - if (!validated) { - scheduleFrequencies().map { it.forEach { it.validate() } } - scheduleStopTimes().forEach { it.validate() } - tripHeadsign() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var scheduleFrequencies: JsonField> = - JsonMissing.of() - private var scheduleStopTimes: JsonField> = - JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopRouteDirectionSchedule: StopRouteDirectionSchedule) = - apply { - this.scheduleFrequencies = - stopRouteDirectionSchedule.scheduleFrequencies - this.scheduleStopTimes = - stopRouteDirectionSchedule.scheduleStopTimes - this.tripHeadsign = stopRouteDirectionSchedule.tripHeadsign - additionalProperties( - stopRouteDirectionSchedule.additionalProperties - ) - } - - fun scheduleFrequencies(scheduleFrequencies: List) = - scheduleFrequencies(JsonField.of(scheduleFrequencies)) - - @JsonProperty("scheduleFrequencies") - @ExcludeMissing - fun scheduleFrequencies( - scheduleFrequencies: JsonField> - ) = apply { this.scheduleFrequencies = scheduleFrequencies } - - fun scheduleStopTimes(scheduleStopTimes: List) = - scheduleStopTimes(JsonField.of(scheduleStopTimes)) - - @JsonProperty("scheduleStopTimes") - @ExcludeMissing - fun scheduleStopTimes( - scheduleStopTimes: JsonField> - ) = apply { this.scheduleStopTimes = scheduleStopTimes } - - fun tripHeadsign(tripHeadsign: String) = - tripHeadsign(JsonField.of(tripHeadsign)) - - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): StopRouteDirectionSchedule = - StopRouteDirectionSchedule( - scheduleFrequencies.map { it.toImmutable() }, - scheduleStopTimes.map { it.toImmutable() }, - tripHeadsign, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = ScheduleStopTime.Builder::class) - @NoAutoDetect - class ScheduleStopTime - private constructor( - private val arrivalEnabled: JsonField, - private val arrivalTime: JsonField, - private val departureEnabled: JsonField, - private val departureTime: JsonField, - private val serviceId: JsonField, - private val stopHeadsign: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") - - fun departureEnabled(): Boolean = - departureEnabled.getRequired("departureEnabled") - - fun departureTime(): Long = departureTime.getRequired("departureTime") - - fun serviceId(): String = serviceId.getRequired("serviceId") - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun _arrivalEnabled() = arrivalEnabled - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime() = arrivalTime - - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled() = departureEnabled - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime() = departureTime - - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign() = stopHeadsign - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ScheduleStopTime = apply { - if (!validated) { - arrivalEnabled() - arrivalTime() - departureEnabled() - departureTime() - serviceId() - stopHeadsign() - tripId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arrivalEnabled: JsonField = JsonMissing.of() - private var arrivalTime: JsonField = JsonMissing.of() - private var departureEnabled: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() - private var stopHeadsign: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(scheduleStopTime: ScheduleStopTime) = apply { - this.arrivalEnabled = scheduleStopTime.arrivalEnabled - this.arrivalTime = scheduleStopTime.arrivalTime - this.departureEnabled = scheduleStopTime.departureEnabled - this.departureTime = scheduleStopTime.departureTime - this.serviceId = scheduleStopTime.serviceId - this.stopHeadsign = scheduleStopTime.stopHeadsign - this.tripId = scheduleStopTime.tripId - additionalProperties(scheduleStopTime.additionalProperties) - } - - fun arrivalEnabled(arrivalEnabled: Boolean) = - arrivalEnabled(JsonField.of(arrivalEnabled)) - - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun arrivalEnabled(arrivalEnabled: JsonField) = apply { - this.arrivalEnabled = arrivalEnabled - } - - fun arrivalTime(arrivalTime: Long) = - arrivalTime(JsonField.of(arrivalTime)) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureEnabled(departureEnabled: Boolean) = - departureEnabled(JsonField.of(departureEnabled)) - - @JsonProperty("departureEnabled") - @ExcludeMissing - fun departureEnabled(departureEnabled: JsonField) = apply { - this.departureEnabled = departureEnabled - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - @JsonProperty("departureTime") - @ExcludeMissing - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - @JsonProperty("serviceId") - @ExcludeMissing - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ScheduleStopTime = - ScheduleStopTime( - arrivalEnabled, - arrivalTime, - departureEnabled, - departureTime, - serviceId, - stopHeadsign, - tripId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleStopTime && this.arrivalEnabled == other.arrivalEnabled && this.arrivalTime == other.arrivalTime && this.departureEnabled == other.departureEnabled && this.departureTime == other.departureTime && this.serviceId == other.serviceId && this.stopHeadsign == other.stopHeadsign && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, stopHeadsign, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ScheduleStopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, stopHeadsign=$stopHeadsign, tripId=$tripId, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = ScheduleFrequency.Builder::class) - @NoAutoDetect - class ScheduleFrequency - private constructor( - private val serviceDate: JsonField, - private val startTime: JsonField, - private val endTime: JsonField, - private val headway: JsonField, - private val serviceId: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - fun startTime(): Long = startTime.getRequired("startTime") - - fun endTime(): Long = endTime.getRequired("endTime") - - fun headway(): Long = headway.getRequired("headway") - - fun serviceId(): String = serviceId.getRequired("serviceId") - - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate() = serviceDate - - @JsonProperty("startTime") @ExcludeMissing fun _startTime() = startTime - - @JsonProperty("endTime") @ExcludeMissing fun _endTime() = endTime - - @JsonProperty("headway") @ExcludeMissing fun _headway() = headway - - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ScheduleFrequency = apply { - if (!validated) { - serviceDate() - startTime() - endTime() - headway() - serviceId() - tripId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var serviceDate: JsonField = JsonMissing.of() - private var startTime: JsonField = JsonMissing.of() - private var endTime: JsonField = JsonMissing.of() - private var headway: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(scheduleFrequency: ScheduleFrequency) = apply { - this.serviceDate = scheduleFrequency.serviceDate - this.startTime = scheduleFrequency.startTime - this.endTime = scheduleFrequency.endTime - this.headway = scheduleFrequency.headway - this.serviceId = scheduleFrequency.serviceId - this.tripId = scheduleFrequency.tripId - additionalProperties(scheduleFrequency.additionalProperties) - } - - fun serviceDate(serviceDate: Long) = - serviceDate(JsonField.of(serviceDate)) - - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun startTime(startTime: Long) = startTime(JsonField.of(startTime)) - - @JsonProperty("startTime") - @ExcludeMissing - fun startTime(startTime: JsonField) = apply { - this.startTime = startTime - } - - fun endTime(endTime: Long) = endTime(JsonField.of(endTime)) - - @JsonProperty("endTime") - @ExcludeMissing - fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - - fun headway(headway: Long) = headway(JsonField.of(headway)) - - @JsonProperty("headway") - @ExcludeMissing - fun headway(headway: JsonField) = apply { this.headway = headway } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - @JsonProperty("serviceId") - @ExcludeMissing - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ScheduleFrequency = - ScheduleFrequency( - serviceDate, - startTime, - endTime, - headway, - serviceId, - tripId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleFrequency && this.serviceDate == other.serviceDate && this.startTime == other.startTime && this.endTime == other.endTime && this.headway == other.headway && this.serviceId == other.serviceId && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(serviceDate, startTime, endTime, headway, serviceId, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ScheduleFrequency{serviceDate=$serviceDate, startTime=$startTime, endTime=$endTime, headway=$headway, serviceId=$serviceId, tripId=$tripId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopRouteDirectionSchedule && this.scheduleFrequencies == other.scheduleFrequencies && this.scheduleStopTimes == other.scheduleStopTimes && this.tripHeadsign == other.tripHeadsign && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(scheduleFrequencies, scheduleStopTimes, tripHeadsign, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopRouteDirectionSchedule{scheduleFrequencies=$scheduleFrequencies, scheduleStopTimes=$scheduleStopTimes, tripHeadsign=$tripHeadsign, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopRouteSchedule && this.routeId == other.routeId && this.stopRouteDirectionSchedules == other.stopRouteDirectionSchedules && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(routeId, stopRouteDirectionSchedules, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopRouteSchedule{routeId=$routeId, stopRouteDirectionSchedules=$stopRouteDirectionSchedules, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.date == other.date && this.stopId == other.stopId && this.stopRouteSchedules == other.stopRouteSchedules && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(date, stopId, stopRouteSchedules, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{date=$date, stopId=$stopId, stopRouteSchedules=$stopRouteSchedules, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleForStopRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ScheduleForStopRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt deleted file mode 100644 index 821db49..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt +++ /dev/null @@ -1,172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class SearchForRouteListParams -constructor( - private val input: String, - private val maxCount: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun input(): String = input - - fun maxCount(): Optional = Optional.ofNullable(maxCount) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.input.let { params.put("input", listOf(it.toString())) } - this.maxCount?.let { params.put("maxCount", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SearchForRouteListParams && this.input == other.input && this.maxCount == other.maxCount && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "SearchForRouteListParams{input=$input, maxCount=$maxCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var input: String? = null - private var maxCount: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(searchForRouteListParams: SearchForRouteListParams) = apply { - this.input = searchForRouteListParams.input - this.maxCount = searchForRouteListParams.maxCount - additionalHeaders(searchForRouteListParams.additionalHeaders) - additionalQueryParams(searchForRouteListParams.additionalQueryParams) - } - - /** 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 } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): SearchForRouteListParams = - SearchForRouteListParams( - checkNotNull(input) { "`input` is required but was not set" }, - maxCount, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt deleted file mode 100644 index d18d1be..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt +++ /dev/null @@ -1,553 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = SearchForRouteListResponse.Builder::class) -@NoAutoDetect -class SearchForRouteListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SearchForRouteListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(searchForRouteListResponse: SearchForRouteListResponse) = apply { - this.code = searchForRouteListResponse.code - this.currentTime = searchForRouteListResponse.currentTime - this.text = searchForRouteListResponse.text - this.version = searchForRouteListResponse.version - this.data = searchForRouteListResponse.data - additionalProperties(searchForRouteListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SearchForRouteListResponse = - SearchForRouteListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val outOfRange: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.outOfRange = data.outOfRange - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - @JsonProperty("outOfRange") - @ExcludeMissing - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - outOfRange, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun id(): String = id.getRequired("id") - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = - Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = - Optional.ofNullable(textColor.getNullable("textColor")) - - fun type(): Long = type.getRequired("type") - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId - - @JsonProperty("color") @ExcludeMissing fun _color() = color - - @JsonProperty("description") @ExcludeMissing fun _description() = description - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName - - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var agencyId: JsonField = JsonMissing.of() - private var color: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var longName: JsonField = JsonMissing.of() - private var nullSafeShortName: JsonField = JsonMissing.of() - private var shortName: JsonField = JsonMissing.of() - private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.agencyId = list.agencyId - this.color = list.color - this.description = list.description - this.id = list.id - this.longName = list.longName - this.nullSafeShortName = list.nullSafeShortName - this.shortName = list.shortName - this.textColor = list.textColor - this.type = list.type - this.url = list.url - additionalProperties(list.additionalProperties) - } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - @JsonProperty("agencyId") - @ExcludeMissing - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun color(color: String) = color(JsonField.of(color)) - - @JsonProperty("color") - @ExcludeMissing - fun color(color: JsonField) = apply { this.color = color } - - fun description(description: String) = description(JsonField.of(description)) - - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun longName(longName: String) = longName(JsonField.of(longName)) - - @JsonProperty("longName") - @ExcludeMissing - fun longName(longName: JsonField) = apply { this.longName = longName } - - fun nullSafeShortName(nullSafeShortName: String) = - nullSafeShortName(JsonField.of(nullSafeShortName)) - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun nullSafeShortName(nullSafeShortName: JsonField) = apply { - this.nullSafeShortName = nullSafeShortName - } - - fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - - @JsonProperty("shortName") - @ExcludeMissing - fun shortName(shortName: JsonField) = apply { this.shortName = shortName } - - fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - - @JsonProperty("textColor") - @ExcludeMissing - fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - - fun type(type: Long) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - agencyId, - color, - description, - id, - longName, - nullSafeShortName, - shortName, - textColor, - type, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.outOfRange == other.outOfRange && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SearchForRouteListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "SearchForRouteListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt deleted file mode 100644 index a4c84eb..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt +++ /dev/null @@ -1,172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class SearchForStopListParams -constructor( - private val input: String, - private val maxCount: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun input(): String = input - - fun maxCount(): Optional = Optional.ofNullable(maxCount) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.input.let { params.put("input", listOf(it.toString())) } - this.maxCount?.let { params.put("maxCount", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SearchForStopListParams && this.input == other.input && this.maxCount == other.maxCount && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "SearchForStopListParams{input=$input, maxCount=$maxCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var input: String? = null - private var maxCount: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(searchForStopListParams: SearchForStopListParams) = apply { - this.input = searchForStopListParams.input - this.maxCount = searchForStopListParams.maxCount - additionalHeaders(searchForStopListParams.additionalHeaders) - additionalQueryParams(searchForStopListParams.additionalQueryParams) - } - - /** 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 } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): SearchForStopListParams = - SearchForStopListParams( - checkNotNull(input) { "`input` is required but was not set" }, - maxCount, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt deleted file mode 100644 index e5437d0..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt +++ /dev/null @@ -1,576 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = SearchForStopListResponse.Builder::class) -@NoAutoDetect -class SearchForStopListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SearchForStopListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(searchForStopListResponse: SearchForStopListResponse) = apply { - this.code = searchForStopListResponse.code - this.currentTime = searchForStopListResponse.currentTime - this.text = searchForStopListResponse.text - this.version = searchForStopListResponse.version - this.data = searchForStopListResponse.data - additionalProperties(searchForStopListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SearchForStopListResponse = - SearchForStopListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val outOfRange: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.outOfRange = data.outOfRange - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - @JsonProperty("outOfRange") - @ExcludeMissing - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - outOfRange, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val code: JsonField, - private val direction: JsonField, - private val id: JsonField, - private val lat: JsonField, - private val locationType: JsonField, - private val lon: JsonField, - private val name: JsonField, - private val parent: JsonField, - private val routeIds: JsonField>, - private val staticRouteIds: JsonField>, - private val wheelchairBoarding: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): kotlin.collections.List = - staticRouteIds.getRequired("staticRouteIds") - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent - - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds - - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = - JsonMissing.of() - private var wheelchairBoarding: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.code = list.code - this.direction = list.direction - this.id = list.id - this.lat = list.lat - this.locationType = list.locationType - this.lon = list.lon - this.name = list.name - this.parent = list.parent - this.routeIds = list.routeIds - this.staticRouteIds = list.staticRouteIds - this.wheelchairBoarding = list.wheelchairBoarding - additionalProperties(list.additionalProperties) - } - - fun code(code: String) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - @JsonProperty("direction") - @ExcludeMissing - fun direction(direction: JsonField) = apply { this.direction = direction } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - @JsonProperty("locationType") - @ExcludeMissing - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - @JsonProperty("parent") - @ExcludeMissing - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: kotlin.collections.List) = - routeIds(JsonField.of(routeIds)) - - @JsonProperty("routeIds") - @ExcludeMissing - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds - } - - fun staticRouteIds(staticRouteIds: kotlin.collections.List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun staticRouteIds(staticRouteIds: JsonField>) = - apply { - this.staticRouteIds = staticRouteIds - } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { - this.wheelchairBoarding = wheelchairBoarding - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - code, - direction, - id, - lat, - locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, - wheelchairBoarding, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.outOfRange == other.outOfRange && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SearchForStopListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "SearchForStopListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt deleted file mode 100644 index 0688ca0..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class ShapeRetrieveParams -constructor( - private val shapeId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun shapeId(): String = shapeId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> shapeId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShapeRetrieveParams && this.shapeId == other.shapeId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(shapeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ShapeRetrieveParams{shapeId=$shapeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var shapeId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(shapeRetrieveParams: ShapeRetrieveParams) = apply { - this.shapeId = shapeRetrieveParams.shapeId - additionalHeaders(shapeRetrieveParams.additionalHeaders) - additionalQueryParams(shapeRetrieveParams.additionalQueryParams) - } - - fun shapeId(shapeId: String) = apply { this.shapeId = shapeId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): ShapeRetrieveParams = - ShapeRetrieveParams( - checkNotNull(shapeId) { "`shapeId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt deleted file mode 100644 index dc71798..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt +++ /dev/null @@ -1,409 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = ShapeRetrieveResponse.Builder::class) -@NoAutoDetect -class ShapeRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ShapeRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(shapeRetrieveResponse: ShapeRetrieveResponse) = apply { - this.code = shapeRetrieveResponse.code - this.currentTime = shapeRetrieveResponse.currentTime - this.text = shapeRetrieveResponse.text - this.version = shapeRetrieveResponse.version - this.data = shapeRetrieveResponse.data - additionalProperties(shapeRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ShapeRetrieveResponse = - ShapeRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun length(): Long = length.getRequired("length") - - fun levels(): Optional = Optional.ofNullable(levels.getNullable("levels")) - - /** Encoded polyline format representing the shape of the path */ - fun points(): String = points.getRequired("points") - - @JsonProperty("length") @ExcludeMissing fun _length() = length - - @JsonProperty("levels") @ExcludeMissing fun _levels() = levels - - /** Encoded polyline format representing the shape of the path */ - @JsonProperty("points") @ExcludeMissing fun _points() = points - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - length() - levels() - points() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var length: JsonField = JsonMissing.of() - private var levels: JsonField = JsonMissing.of() - private var points: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.length = entry.length - this.levels = entry.levels - this.points = entry.points - additionalProperties(entry.additionalProperties) - } - - fun length(length: Long) = length(JsonField.of(length)) - - @JsonProperty("length") - @ExcludeMissing - fun length(length: JsonField) = apply { this.length = length } - - fun levels(levels: String) = levels(JsonField.of(levels)) - - @JsonProperty("levels") - @ExcludeMissing - fun levels(levels: JsonField) = apply { this.levels = levels } - - /** Encoded polyline format representing the shape of the path */ - fun points(points: String) = points(JsonField.of(points)) - - /** Encoded polyline format representing the shape of the path */ - @JsonProperty("points") - @ExcludeMissing - fun points(points: JsonField) = apply { this.points = points } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - length, - levels, - points, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.length == other.length && this.levels == other.levels && this.points == other.points && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(length, levels, points, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShapeRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ShapeRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt deleted file mode 100644 index 0db9961..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class StopIdsForAgencyListParams -constructor( - private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun agencyId(): String = agencyId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopIdsForAgencyListParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(stopIdsForAgencyListParams: StopIdsForAgencyListParams) = apply { - this.agencyId = stopIdsForAgencyListParams.agencyId - additionalHeaders(stopIdsForAgencyListParams.additionalHeaders) - additionalQueryParams(stopIdsForAgencyListParams.additionalQueryParams) - } - - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): StopIdsForAgencyListParams = - StopIdsForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt deleted file mode 100644 index b8cebb1..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt +++ /dev/null @@ -1,299 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = StopIdsForAgencyListResponse.Builder::class) -@NoAutoDetect -class StopIdsForAgencyListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopIdsForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopIdsForAgencyListResponse: StopIdsForAgencyListResponse) = apply { - this.code = stopIdsForAgencyListResponse.code - this.currentTime = stopIdsForAgencyListResponse.currentTime - this.text = stopIdsForAgencyListResponse.text - this.version = stopIdsForAgencyListResponse.version - this.data = stopIdsForAgencyListResponse.data - additionalProperties(stopIdsForAgencyListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StopIdsForAgencyListResponse = - StopIdsForAgencyListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - references, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopIdsForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopIdsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt deleted file mode 100644 index f48cb58..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class StopRetrieveParams -constructor( - private val stopId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun stopId(): String = stopId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopRetrieveParams && this.stopId == other.stopId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopRetrieveParams{stopId=$stopId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var stopId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(stopRetrieveParams: StopRetrieveParams) = apply { - this.stopId = stopRetrieveParams.stopId - additionalHeaders(stopRetrieveParams.additionalHeaders) - additionalQueryParams(stopRetrieveParams.additionalQueryParams) - } - - fun stopId(stopId: String) = apply { this.stopId = stopId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): StopRetrieveParams = - StopRetrieveParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt deleted file mode 100644 index c94ac1e..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt +++ /dev/null @@ -1,538 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = StopRetrieveResponse.Builder::class) -@NoAutoDetect -class StopRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopRetrieveResponse: StopRetrieveResponse) = apply { - this.code = stopRetrieveResponse.code - this.currentTime = stopRetrieveResponse.currentTime - this.text = stopRetrieveResponse.text - this.version = stopRetrieveResponse.version - this.data = stopRetrieveResponse.data - additionalProperties(stopRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StopRetrieveResponse = - StopRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val code: JsonField, - private val direction: JsonField, - private val id: JsonField, - private val lat: JsonField, - private val locationType: JsonField, - private val lon: JsonField, - private val name: JsonField, - private val parent: JsonField, - private val routeIds: JsonField>, - private val staticRouteIds: JsonField>, - private val wheelchairBoarding: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent - - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds - - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = JsonMissing.of() - private var wheelchairBoarding: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.code = entry.code - this.direction = entry.direction - this.id = entry.id - this.lat = entry.lat - this.locationType = entry.locationType - this.lon = entry.lon - this.name = entry.name - this.parent = entry.parent - this.routeIds = entry.routeIds - this.staticRouteIds = entry.staticRouteIds - this.wheelchairBoarding = entry.wheelchairBoarding - additionalProperties(entry.additionalProperties) - } - - fun code(code: String) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - @JsonProperty("direction") - @ExcludeMissing - fun direction(direction: JsonField) = apply { this.direction = direction } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - @JsonProperty("locationType") - @ExcludeMissing - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - @JsonProperty("parent") - @ExcludeMissing - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - - @JsonProperty("routeIds") - @ExcludeMissing - fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } - - fun staticRouteIds(staticRouteIds: List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds - } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { - this.wheelchairBoarding = wheelchairBoarding - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - code, - direction, - id, - lat, - locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, - wheelchairBoarding, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt deleted file mode 100644 index 5c4c365..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class StopsForAgencyListParams -constructor( - private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun agencyId(): String = agencyId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForAgencyListParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(stopsForAgencyListParams: StopsForAgencyListParams) = apply { - this.agencyId = stopsForAgencyListParams.agencyId - additionalHeaders(stopsForAgencyListParams.additionalHeaders) - additionalQueryParams(stopsForAgencyListParams.additionalQueryParams) - } - - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): StopsForAgencyListParams = - StopsForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt deleted file mode 100644 index 56a8389..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt +++ /dev/null @@ -1,480 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = StopsForAgencyListResponse.Builder::class) -@NoAutoDetect -class StopsForAgencyListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val limitExceeded: JsonField, - private val outOfRange: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun outOfRange(): Optional = Optional.ofNullable(outOfRange.getNullable("outOfRange")) - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopsForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - limitExceeded() - outOfRange() - list().forEach { it.validate() } - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var limitExceeded: JsonField = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopsForAgencyListResponse: StopsForAgencyListResponse) = apply { - this.code = stopsForAgencyListResponse.code - this.currentTime = stopsForAgencyListResponse.currentTime - this.text = stopsForAgencyListResponse.text - this.version = stopsForAgencyListResponse.version - this.limitExceeded = stopsForAgencyListResponse.limitExceeded - this.outOfRange = stopsForAgencyListResponse.outOfRange - this.list = stopsForAgencyListResponse.list - this.references = stopsForAgencyListResponse.references - additionalProperties(stopsForAgencyListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - @JsonProperty("outOfRange") - @ExcludeMissing - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { this.references = references } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StopsForAgencyListResponse = - StopsForAgencyListResponse( - code, - currentTime, - text, - version, - limitExceeded, - outOfRange, - list.map { it.toImmutable() }, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val code: JsonField, - private val direction: JsonField, - private val id: JsonField, - private val lat: JsonField, - private val locationType: JsonField, - private val lon: JsonField, - private val name: JsonField, - private val parent: JsonField, - private val routeIds: JsonField>, - private val staticRouteIds: JsonField>, - private val wheelchairBoarding: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): kotlin.collections.List = - staticRouteIds.getRequired("staticRouteIds") - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent - - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds - - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = - JsonMissing.of() - private var wheelchairBoarding: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.code = list.code - this.direction = list.direction - this.id = list.id - this.lat = list.lat - this.locationType = list.locationType - this.lon = list.lon - this.name = list.name - this.parent = list.parent - this.routeIds = list.routeIds - this.staticRouteIds = list.staticRouteIds - this.wheelchairBoarding = list.wheelchairBoarding - additionalProperties(list.additionalProperties) - } - - fun code(code: String) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - @JsonProperty("direction") - @ExcludeMissing - fun direction(direction: JsonField) = apply { this.direction = direction } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - @JsonProperty("locationType") - @ExcludeMissing - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - @JsonProperty("parent") - @ExcludeMissing - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: kotlin.collections.List) = - routeIds(JsonField.of(routeIds)) - - @JsonProperty("routeIds") - @ExcludeMissing - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds - } - - fun staticRouteIds(staticRouteIds: kotlin.collections.List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds - } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { - this.wheelchairBoarding = wheelchairBoarding - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - code, - direction, - id, - lat, - locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, - wheelchairBoarding, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.limitExceeded == other.limitExceeded && this.outOfRange == other.outOfRange && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, limitExceeded, outOfRange, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, limitExceeded=$limitExceeded, outOfRange=$outOfRange, list=$list, references=$references, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt deleted file mode 100644 index 5a72da8..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt +++ /dev/null @@ -1,210 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class StopsForLocationListParams -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: Map>, - private val additionalQueryParams: Map>, -) { - - 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) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.lat.let { params.put("lat", listOf(it.toString())) } - this.lon.let { params.put("lon", listOf(it.toString())) } - this.latSpan?.let { params.put("latSpan", listOf(it.toString())) } - this.lonSpan?.let { params.put("lonSpan", listOf(it.toString())) } - this.query?.let { params.put("query", listOf(it.toString())) } - this.radius?.let { params.put("radius", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForLocationListParams && this.lat == other.lat && this.lon == other.lon && this.latSpan == other.latSpan && this.lonSpan == other.lonSpan && this.query == other.query && this.radius == other.radius && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(lat, lon, latSpan, lonSpan, query, radius, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopsForLocationListParams{lat=$lat, lon=$lon, latSpan=$latSpan, lonSpan=$lonSpan, query=$query, radius=$radius, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - 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: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(stopsForLocationListParams: StopsForLocationListParams) = apply { - this.lat = stopsForLocationListParams.lat - this.lon = stopsForLocationListParams.lon - this.latSpan = stopsForLocationListParams.latSpan - this.lonSpan = stopsForLocationListParams.lonSpan - this.query = stopsForLocationListParams.query - this.radius = stopsForLocationListParams.radius - additionalHeaders(stopsForLocationListParams.additionalHeaders) - additionalQueryParams(stopsForLocationListParams.additionalQueryParams) - } - - 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 } - - /** An alternative to radius to set the search bounding box (optional) */ - fun lonSpan(lonSpan: Double) = apply { this.lonSpan = lonSpan } - - /** A search query string to filter the results */ - fun query(query: String) = apply { this.query = query } - - /** The radius in meters to search within */ - fun radius(radius: Double) = apply { this.radius = radius } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): StopsForLocationListParams = - StopsForLocationListParams( - checkNotNull(lat) { "`lat` is required but was not set" }, - checkNotNull(lon) { "`lon` is required but was not set" }, - latSpan, - lonSpan, - query, - radius, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt deleted file mode 100644 index 9a7970a..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt +++ /dev/null @@ -1,577 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = StopsForLocationListResponse.Builder::class) -@NoAutoDetect -class StopsForLocationListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopsForLocationListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopsForLocationListResponse: StopsForLocationListResponse) = apply { - this.code = stopsForLocationListResponse.code - this.currentTime = stopsForLocationListResponse.currentTime - this.text = stopsForLocationListResponse.text - this.version = stopsForLocationListResponse.version - this.data = stopsForLocationListResponse.data - additionalProperties(stopsForLocationListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StopsForLocationListResponse = - StopsForLocationListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val outOfRange: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun outOfRange(): Optional = - Optional.ofNullable(outOfRange.getNullable("outOfRange")) - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - outOfRange() - list().forEach { it.validate() } - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.outOfRange = data.outOfRange - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - @JsonProperty("outOfRange") - @ExcludeMissing - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - outOfRange, - list.map { it.toImmutable() }, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val code: JsonField, - private val direction: JsonField, - private val id: JsonField, - private val lat: JsonField, - private val locationType: JsonField, - private val lon: JsonField, - private val name: JsonField, - private val parent: JsonField, - private val routeIds: JsonField>, - private val staticRouteIds: JsonField>, - private val wheelchairBoarding: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): kotlin.collections.List = - staticRouteIds.getRequired("staticRouteIds") - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent - - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds - - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = - JsonMissing.of() - private var wheelchairBoarding: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.code = list.code - this.direction = list.direction - this.id = list.id - this.lat = list.lat - this.locationType = list.locationType - this.lon = list.lon - this.name = list.name - this.parent = list.parent - this.routeIds = list.routeIds - this.staticRouteIds = list.staticRouteIds - this.wheelchairBoarding = list.wheelchairBoarding - additionalProperties(list.additionalProperties) - } - - fun code(code: String) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - @JsonProperty("direction") - @ExcludeMissing - fun direction(direction: JsonField) = apply { this.direction = direction } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - @JsonProperty("locationType") - @ExcludeMissing - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - @JsonProperty("parent") - @ExcludeMissing - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: kotlin.collections.List) = - routeIds(JsonField.of(routeIds)) - - @JsonProperty("routeIds") - @ExcludeMissing - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds - } - - fun staticRouteIds(staticRouteIds: kotlin.collections.List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun staticRouteIds(staticRouteIds: JsonField>) = - apply { - this.staticRouteIds = staticRouteIds - } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { - this.wheelchairBoarding = wheelchairBoarding - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - code, - direction, - id, - lat, - locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, - wheelchairBoarding, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.outOfRange == other.outOfRange && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, outOfRange, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, outOfRange=$outOfRange, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForLocationListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopsForLocationListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt deleted file mode 100644 index 6a20455..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class StopsForRouteListParams -constructor( - private val routeId: String, - private val includePolylines: Boolean?, - private val time: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun routeId(): String = routeId - - fun includePolylines(): Optional = Optional.ofNullable(includePolylines) - - fun time(): Optional = Optional.ofNullable(time) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.includePolylines?.let { params.put("includePolylines", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> routeId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForRouteListParams && this.routeId == other.routeId && this.includePolylines == other.includePolylines && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(routeId, includePolylines, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopsForRouteListParams{routeId=$routeId, includePolylines=$includePolylines, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var routeId: String? = null - private var includePolylines: Boolean? = null - private var time: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(stopsForRouteListParams: StopsForRouteListParams) = apply { - this.routeId = stopsForRouteListParams.routeId - this.includePolylines = stopsForRouteListParams.includePolylines - this.time = stopsForRouteListParams.time - additionalHeaders(stopsForRouteListParams.additionalHeaders) - additionalQueryParams(stopsForRouteListParams.additionalQueryParams) - } - - fun routeId(routeId: String) = apply { this.routeId = routeId } - - /** Include polyline elements in the response (default true) */ - fun includePolylines(includePolylines: Boolean) = apply { - this.includePolylines = includePolylines - } - - /** Specify service date (YYYY-MM-DD or epoch) (default today) */ - fun time(time: String) = apply { this.time = time } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): StopsForRouteListParams = - StopsForRouteListParams( - checkNotNull(routeId) { "`routeId` is required but was not set" }, - includePolylines, - time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt deleted file mode 100644 index 70761aa..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt +++ /dev/null @@ -1,940 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = StopsForRouteListResponse.Builder::class) -@NoAutoDetect -class StopsForRouteListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopsForRouteListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopsForRouteListResponse: StopsForRouteListResponse) = apply { - this.code = stopsForRouteListResponse.code - this.currentTime = stopsForRouteListResponse.currentTime - this.text = stopsForRouteListResponse.text - this.version = stopsForRouteListResponse.version - this.data = stopsForRouteListResponse.data - additionalProperties(stopsForRouteListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StopsForRouteListResponse = - StopsForRouteListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val polylines: JsonField>, - private val routeId: JsonField, - private val stopGroupings: JsonField>, - private val stopIds: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun polylines(): Optional> = - Optional.ofNullable(polylines.getNullable("polylines")) - - fun routeId(): Optional = Optional.ofNullable(routeId.getNullable("routeId")) - - fun stopGroupings(): Optional> = - Optional.ofNullable(stopGroupings.getNullable("stopGroupings")) - - fun stopIds(): Optional> = - Optional.ofNullable(stopIds.getNullable("stopIds")) - - @JsonProperty("polylines") @ExcludeMissing fun _polylines() = polylines - - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - @JsonProperty("stopGroupings") @ExcludeMissing fun _stopGroupings() = stopGroupings - - @JsonProperty("stopIds") @ExcludeMissing fun _stopIds() = stopIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - polylines().map { it.forEach { it.validate() } } - routeId() - stopGroupings().map { it.forEach { it.validate() } } - stopIds() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var polylines: JsonField> = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() - private var stopGroupings: JsonField> = JsonMissing.of() - private var stopIds: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.polylines = entry.polylines - this.routeId = entry.routeId - this.stopGroupings = entry.stopGroupings - this.stopIds = entry.stopIds - additionalProperties(entry.additionalProperties) - } - - fun polylines(polylines: List) = polylines(JsonField.of(polylines)) - - @JsonProperty("polylines") - @ExcludeMissing - fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines - } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - @JsonProperty("routeId") - @ExcludeMissing - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun stopGroupings(stopGroupings: List) = - stopGroupings(JsonField.of(stopGroupings)) - - @JsonProperty("stopGroupings") - @ExcludeMissing - fun stopGroupings(stopGroupings: JsonField>) = apply { - this.stopGroupings = stopGroupings - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - - @JsonProperty("stopIds") - @ExcludeMissing - fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - polylines.map { it.toImmutable() }, - routeId, - stopGroupings.map { it.toImmutable() }, - stopIds.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Polyline.Builder::class) - @NoAutoDetect - class Polyline - private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun length(): Optional = Optional.ofNullable(length.getNullable("length")) - - fun levels(): Optional = Optional.ofNullable(levels.getNullable("levels")) - - fun points(): Optional = Optional.ofNullable(points.getNullable("points")) - - @JsonProperty("length") @ExcludeMissing fun _length() = length - - @JsonProperty("levels") @ExcludeMissing fun _levels() = levels - - @JsonProperty("points") @ExcludeMissing fun _points() = points - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Polyline = apply { - if (!validated) { - length() - levels() - points() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - 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 { - this.length = polyline.length - this.levels = polyline.levels - this.points = polyline.points - additionalProperties(polyline.additionalProperties) - } - - fun length(length: Long) = length(JsonField.of(length)) - - @JsonProperty("length") - @ExcludeMissing - fun length(length: JsonField) = apply { this.length = length } - - fun levels(levels: String) = levels(JsonField.of(levels)) - - @JsonProperty("levels") - @ExcludeMissing - fun levels(levels: JsonField) = apply { this.levels = levels } - - fun points(points: String) = points(JsonField.of(points)) - - @JsonProperty("points") - @ExcludeMissing - fun points(points: JsonField) = apply { this.points = points } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Polyline = - Polyline( - length, - levels, - points, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Polyline && this.length == other.length && this.levels == other.levels && this.points == other.points && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(length, levels, points, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = StopGrouping.Builder::class) - @NoAutoDetect - class StopGrouping - private constructor( - private val id: JsonField, - private val name: JsonField, - private val polylines: JsonField>, - private val stopIds: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun polylines(): Optional> = - Optional.ofNullable(polylines.getNullable("polylines")) - - fun stopIds(): Optional> = - Optional.ofNullable(stopIds.getNullable("stopIds")) - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("polylines") @ExcludeMissing fun _polylines() = polylines - - @JsonProperty("stopIds") @ExcludeMissing fun _stopIds() = stopIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopGrouping = apply { - if (!validated) { - id() - name().map { it.validate() } - polylines().map { it.forEach { it.validate() } } - stopIds() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var polylines: JsonField> = JsonMissing.of() - private var stopIds: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopGrouping: StopGrouping) = apply { - this.id = stopGrouping.id - this.name = stopGrouping.name - this.polylines = stopGrouping.polylines - this.stopIds = stopGrouping.stopIds - additionalProperties(stopGrouping.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: Name) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun polylines(polylines: List) = polylines(JsonField.of(polylines)) - - @JsonProperty("polylines") - @ExcludeMissing - fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - - @JsonProperty("stopIds") - @ExcludeMissing - fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StopGrouping = - StopGrouping( - id, - name, - polylines.map { it.toImmutable() }, - stopIds.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Name.Builder::class) - @NoAutoDetect - class Name - private constructor( - private val name: JsonField, - private val names: JsonField>, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun names(): Optional> = - Optional.ofNullable(names.getNullable("names")) - - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("names") @ExcludeMissing fun _names() = names - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Name = apply { - if (!validated) { - name() - names() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var names: JsonField> = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - this.names = name.names - this.type = name.type - additionalProperties(name.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun names(names: List) = names(JsonField.of(names)) - - @JsonProperty("names") - @ExcludeMissing - fun names(names: JsonField>) = apply { this.names = names } - - fun type(type: String) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Name = - Name( - name, - names.map { it.toImmutable() }, - type, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Name && this.name == other.name && this.names == other.names && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, names, type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Polyline.Builder::class) - @NoAutoDetect - class Polyline - private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun length(): Optional = Optional.ofNullable(length.getNullable("length")) - - fun levels(): Optional = - Optional.ofNullable(levels.getNullable("levels")) - - fun points(): Optional = - Optional.ofNullable(points.getNullable("points")) - - @JsonProperty("length") @ExcludeMissing fun _length() = length - - @JsonProperty("levels") @ExcludeMissing fun _levels() = levels - - @JsonProperty("points") @ExcludeMissing fun _points() = points - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Polyline = apply { - if (!validated) { - length() - levels() - points() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - 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 { - this.length = polyline.length - this.levels = polyline.levels - this.points = polyline.points - additionalProperties(polyline.additionalProperties) - } - - fun length(length: Long) = length(JsonField.of(length)) - - @JsonProperty("length") - @ExcludeMissing - fun length(length: JsonField) = apply { this.length = length } - - fun levels(levels: String) = levels(JsonField.of(levels)) - - @JsonProperty("levels") - @ExcludeMissing - fun levels(levels: JsonField) = apply { this.levels = levels } - - fun points(points: String) = points(JsonField.of(points)) - - @JsonProperty("points") - @ExcludeMissing - fun points(points: JsonField) = apply { this.points = points } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Polyline = - Polyline( - length, - levels, - points, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Polyline && this.length == other.length && this.levels == other.levels && this.points == other.points && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(length, levels, points, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopGrouping && this.id == other.id && this.name == other.name && this.polylines == other.polylines && this.stopIds == other.stopIds && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, name, polylines, stopIds, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.polylines == other.polylines && this.routeId == other.routeId && this.stopGroupings == other.stopGroupings && this.stopIds == other.stopIds && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForRouteListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopsForRouteListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt deleted file mode 100644 index 1564725..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt +++ /dev/null @@ -1,226 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class TripDetailRetrieveParams -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: Map>, - private val additionalQueryParams: Map>, -) { - - fun tripId(): String = tripId - - fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) - - fun includeStatus(): Optional = Optional.ofNullable(includeStatus) - - fun includeTrip(): Optional = Optional.ofNullable(includeTrip) - - fun serviceDate(): Optional = Optional.ofNullable(serviceDate) - - fun time(): Optional = Optional.ofNullable(time) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.includeSchedule?.let { params.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { params.put("includeStatus", listOf(it.toString())) } - this.includeTrip?.let { params.put("includeTrip", listOf(it.toString())) } - this.serviceDate?.let { params.put("serviceDate", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> tripId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripDetailRetrieveParams && this.tripId == other.tripId && this.includeSchedule == other.includeSchedule && this.includeStatus == other.includeStatus && this.includeTrip == other.includeTrip && this.serviceDate == other.serviceDate && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(tripId, includeSchedule, includeStatus, includeTrip, serviceDate, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripDetailRetrieveParams{tripId=$tripId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, includeTrip=$includeTrip, serviceDate=$serviceDate, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - 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: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(tripDetailRetrieveParams: TripDetailRetrieveParams) = apply { - this.tripId = tripDetailRetrieveParams.tripId - this.includeSchedule = tripDetailRetrieveParams.includeSchedule - this.includeStatus = tripDetailRetrieveParams.includeStatus - this.includeTrip = tripDetailRetrieveParams.includeTrip - this.serviceDate = tripDetailRetrieveParams.serviceDate - this.time = tripDetailRetrieveParams.time - additionalHeaders(tripDetailRetrieveParams.additionalHeaders) - additionalQueryParams(tripDetailRetrieveParams.additionalQueryParams) - } - - fun tripId(tripId: String) = apply { this.tripId = tripId } - - /** - * Whether to include the full schedule element in the tripDetails section (defaults to - * true). - */ - fun includeSchedule(includeSchedule: Boolean) = apply { - this.includeSchedule = includeSchedule - } - - /** - * Whether to include the full status element in the tripDetails section (defaults to true). - */ - fun includeStatus(includeStatus: Boolean) = apply { this.includeStatus = includeStatus } - - /** - * Whether to include the full trip element in the references section (defaults to true). - */ - fun includeTrip(includeTrip: Boolean) = apply { this.includeTrip = includeTrip } - - /** Service date for the trip as Unix time in milliseconds (optional). */ - fun serviceDate(serviceDate: Long) = apply { this.serviceDate = serviceDate } - - /** Time parameter to query the system at a specific time (optional). */ - fun time(time: Long) = apply { this.time = time } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): TripDetailRetrieveParams = - TripDetailRetrieveParams( - checkNotNull(tripId) { "`tripId` is required but was not set" }, - includeSchedule, - includeStatus, - includeTrip, - serviceDate, - time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt deleted file mode 100644 index dcb12a7..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt +++ /dev/null @@ -1,1846 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = TripDetailRetrieveResponse.Builder::class) -@NoAutoDetect -class TripDetailRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripDetailRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tripDetailRetrieveResponse: TripDetailRetrieveResponse) = apply { - this.code = tripDetailRetrieveResponse.code - this.currentTime = tripDetailRetrieveResponse.currentTime - this.text = tripDetailRetrieveResponse.text - this.version = tripDetailRetrieveResponse.version - this.data = tripDetailRetrieveResponse.data - additionalProperties(tripDetailRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TripDetailRetrieveResponse = - TripDetailRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val frequency: JsonField, - private val schedule: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun schedule(): Optional = - Optional.ofNullable(schedule.getNullable("schedule")) - - fun serviceDate(): Optional = - Optional.ofNullable(serviceDate.getNullable("serviceDate")) - - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - @JsonProperty("schedule") @ExcludeMissing fun _schedule() = schedule - - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - frequency() - schedule().map { it.validate() } - serviceDate() - situationIds() - status().map { it.validate() } - tripId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var frequency: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.frequency = entry.frequency - this.schedule = entry.schedule - this.serviceDate = entry.serviceDate - this.situationIds = entry.situationIds - this.status = entry.status - this.tripId = entry.tripId - additionalProperties(entry.additionalProperties) - } - - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - @JsonProperty("schedule") - @ExcludeMissing - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - frequency, - schedule, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - tripId, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Schedule.Builder::class) - @NoAutoDetect - class Schedule - private constructor( - private val frequency: JsonField, - private val nextTripId: JsonField, - private val previousTripId: JsonField, - private val stopTimes: JsonField>, - private val timeZone: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun nextTripId(): String = nextTripId.getRequired("nextTripId") - - fun previousTripId(): String = previousTripId.getRequired("previousTripId") - - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - - fun timeZone(): String = timeZone.getRequired("timeZone") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - @JsonProperty("nextTripId") @ExcludeMissing fun _nextTripId() = nextTripId - - @JsonProperty("previousTripId") - @ExcludeMissing - fun _previousTripId() = previousTripId - - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Schedule = apply { - if (!validated) { - frequency() - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField = JsonMissing.of() - private var previousTripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - this.frequency = schedule.frequency - this.nextTripId = schedule.nextTripId - this.previousTripId = schedule.previousTripId - this.stopTimes = schedule.stopTimes - this.timeZone = schedule.timeZone - additionalProperties(schedule.additionalProperties) - } - - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - - @JsonProperty("nextTripId") - @ExcludeMissing - fun nextTripId(nextTripId: JsonField) = apply { - this.nextTripId = nextTripId - } - - fun previousTripId(previousTripId: String) = - previousTripId(JsonField.of(previousTripId)) - - @JsonProperty("previousTripId") - @ExcludeMissing - fun previousTripId(previousTripId: JsonField) = apply { - this.previousTripId = previousTripId - } - - fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - - @JsonProperty("stopTimes") - @ExcludeMissing - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes - } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - @JsonProperty("timeZone") - @ExcludeMissing - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Schedule = - Schedule( - frequency, - nextTripId, - previousTripId, - stopTimes.map { it.toImmutable() }, - timeZone, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = StopTime.Builder::class) - @NoAutoDetect - class StopTime - private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - - fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) - - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = - Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime() = departureTime - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy - - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign - - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - 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 { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) - } - - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - @JsonProperty("departureTime") - @ExcludeMissing - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): StopTime = - StopTime( - arrivalTime, - departureTime, - distanceAlongTrip, - historicalOccupancy, - stopHeadsign, - stopId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schedule && this.frequency == other.frequency && this.nextTripId == other.nextTripId && this.previousTripId == other.previousTripId && this.stopTimes == other.stopTimes && this.timeZone == other.timeZone && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Status.Builder::class) - @NoAutoDetect - class Status - private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount() = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Status = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() - private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() - private var lastKnownLocation: JsonField = JsonMissing.of() - private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var nextStop: JsonField = JsonMissing.of() - private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() - private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(status: Status) = apply { - this.activeTripId = status.activeTripId - this.blockTripSequence = status.blockTripSequence - this.closestStop = status.closestStop - this.closestStopTimeOffset = status.closestStopTimeOffset - this.distanceAlongTrip = status.distanceAlongTrip - this.frequency = status.frequency - this.lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - this.lastKnownLocation = status.lastKnownLocation - this.lastKnownOrientation = status.lastKnownOrientation - this.lastLocationUpdateTime = status.lastLocationUpdateTime - this.lastUpdateTime = status.lastUpdateTime - this.nextStop = status.nextStop - this.nextStopTimeOffset = status.nextStopTimeOffset - this.occupancyCapacity = status.occupancyCapacity - this.occupancyCount = status.occupancyCount - this.occupancyStatus = status.occupancyStatus - this.orientation = status.orientation - this.phase = status.phase - this.position = status.position - this.predicted = status.predicted - this.scheduleDeviation = status.scheduleDeviation - this.scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - this.serviceDate = status.serviceDate - this.situationIds = status.situationIds - this.status = status.status - this.totalDistanceAlongTrip = status.totalDistanceAlongTrip - this.vehicleId = status.vehicleId - additionalProperties(status.additionalProperties) - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun activeTripId(activeTripId: JsonField) = apply { - this.activeTripId = activeTripId - } - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun closestStop(closestStop: JsonField) = apply { - this.closestStop = closestStop - } - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = - lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = - apply { - this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip - } - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun lastKnownLocation(lastKnownLocation: JsonField) = apply { - this.lastKnownLocation = lastKnownLocation - } - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: Double) = - lastKnownOrientation(JsonField.of(lastKnownOrientation)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: Long) = - nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing - fun phase(phase: JsonField) = apply { this.phase = phase } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - fun scheduleDeviation(scheduleDeviation: Long) = - scheduleDeviation(JsonField.of(scheduleDeviation)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun scheduleDeviation(scheduleDeviation: JsonField) = apply { - this.scheduleDeviation = scheduleDeviation - } - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { - this.totalDistanceAlongTrip = totalDistanceAlongTrip - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Status = - Status( - activeTripId, - blockTripSequence, - closestStop, - closestStopTimeOffset, - distanceAlongTrip, - frequency, - lastKnownDistanceAlongTrip, - lastKnownLocation, - lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, - nextStop, - nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, - orientation, - phase, - position, - predicted, - scheduleDeviation, - scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) - @NoAutoDetect - class LastKnownLocation - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) - } - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) - @NoAutoDetect - class Position - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) - } - - /** Latitude of the current position of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the current position of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.frequency == other.frequency && this.schedule == other.schedule && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, schedule, serviceDate, situationIds, status, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, tripId=$tripId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripDetailRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripDetailRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt deleted file mode 100644 index 2d2527b..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt +++ /dev/null @@ -1,218 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class TripForVehicleRetrieveParams -constructor( - private val vehicleId: String, - private val includeSchedule: Boolean?, - private val includeStatus: Boolean?, - private val includeTrip: Boolean?, - private val time: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun vehicleId(): String = vehicleId - - fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) - - fun includeStatus(): Optional = Optional.ofNullable(includeStatus) - - fun includeTrip(): Optional = Optional.ofNullable(includeTrip) - - fun time(): Optional = Optional.ofNullable(time) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.includeSchedule?.let { params.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { params.put("includeStatus", listOf(it.toString())) } - this.includeTrip?.let { params.put("includeTrip", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> vehicleId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripForVehicleRetrieveParams && this.vehicleId == other.vehicleId && this.includeSchedule == other.includeSchedule && this.includeStatus == other.includeStatus && this.includeTrip == other.includeTrip && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(vehicleId, includeSchedule, includeStatus, includeTrip, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripForVehicleRetrieveParams{vehicleId=$vehicleId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, includeTrip=$includeTrip, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - 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: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(tripForVehicleRetrieveParams: TripForVehicleRetrieveParams) = apply { - this.vehicleId = tripForVehicleRetrieveParams.vehicleId - this.includeSchedule = tripForVehicleRetrieveParams.includeSchedule - this.includeStatus = tripForVehicleRetrieveParams.includeStatus - this.includeTrip = tripForVehicleRetrieveParams.includeTrip - this.time = tripForVehicleRetrieveParams.time - additionalHeaders(tripForVehicleRetrieveParams.additionalHeaders) - additionalQueryParams(tripForVehicleRetrieveParams.additionalQueryParams) - } - - fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } - - /** - * Determines whether full element is included in the section. - * Defaults to false. - */ - fun includeSchedule(includeSchedule: Boolean) = apply { - this.includeSchedule = includeSchedule - } - - /** - * Determines whether the full element is included in the section. - * Defaults to true. - */ - fun includeStatus(includeStatus: Boolean) = apply { this.includeStatus = includeStatus } - - /** - * Determines whether full element is included in the section. - * Defaults to false. - */ - fun includeTrip(includeTrip: Boolean) = apply { this.includeTrip = includeTrip } - - /** Time parameter to query the system at a specific time (optional). */ - fun time(time: Long) = apply { this.time = time } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): TripForVehicleRetrieveParams = - TripForVehicleRetrieveParams( - checkNotNull(vehicleId) { "`vehicleId` is required but was not set" }, - includeSchedule, - includeStatus, - includeTrip, - time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt deleted file mode 100644 index f81f2a8..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt +++ /dev/null @@ -1,1846 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = TripForVehicleRetrieveResponse.Builder::class) -@NoAutoDetect -class TripForVehicleRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripForVehicleRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tripForVehicleRetrieveResponse: TripForVehicleRetrieveResponse) = apply { - this.code = tripForVehicleRetrieveResponse.code - this.currentTime = tripForVehicleRetrieveResponse.currentTime - this.text = tripForVehicleRetrieveResponse.text - this.version = tripForVehicleRetrieveResponse.version - this.data = tripForVehicleRetrieveResponse.data - additionalProperties(tripForVehicleRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TripForVehicleRetrieveResponse = - TripForVehicleRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val frequency: JsonField, - private val schedule: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun schedule(): Optional = - Optional.ofNullable(schedule.getNullable("schedule")) - - fun serviceDate(): Optional = - Optional.ofNullable(serviceDate.getNullable("serviceDate")) - - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - @JsonProperty("schedule") @ExcludeMissing fun _schedule() = schedule - - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - frequency() - schedule().map { it.validate() } - serviceDate() - situationIds() - status().map { it.validate() } - tripId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var frequency: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.frequency = entry.frequency - this.schedule = entry.schedule - this.serviceDate = entry.serviceDate - this.situationIds = entry.situationIds - this.status = entry.status - this.tripId = entry.tripId - additionalProperties(entry.additionalProperties) - } - - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - @JsonProperty("schedule") - @ExcludeMissing - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - frequency, - schedule, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - tripId, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Schedule.Builder::class) - @NoAutoDetect - class Schedule - private constructor( - private val frequency: JsonField, - private val nextTripId: JsonField, - private val previousTripId: JsonField, - private val stopTimes: JsonField>, - private val timeZone: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun nextTripId(): String = nextTripId.getRequired("nextTripId") - - fun previousTripId(): String = previousTripId.getRequired("previousTripId") - - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - - fun timeZone(): String = timeZone.getRequired("timeZone") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - @JsonProperty("nextTripId") @ExcludeMissing fun _nextTripId() = nextTripId - - @JsonProperty("previousTripId") - @ExcludeMissing - fun _previousTripId() = previousTripId - - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Schedule = apply { - if (!validated) { - frequency() - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField = JsonMissing.of() - private var previousTripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - this.frequency = schedule.frequency - this.nextTripId = schedule.nextTripId - this.previousTripId = schedule.previousTripId - this.stopTimes = schedule.stopTimes - this.timeZone = schedule.timeZone - additionalProperties(schedule.additionalProperties) - } - - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - - @JsonProperty("nextTripId") - @ExcludeMissing - fun nextTripId(nextTripId: JsonField) = apply { - this.nextTripId = nextTripId - } - - fun previousTripId(previousTripId: String) = - previousTripId(JsonField.of(previousTripId)) - - @JsonProperty("previousTripId") - @ExcludeMissing - fun previousTripId(previousTripId: JsonField) = apply { - this.previousTripId = previousTripId - } - - fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - - @JsonProperty("stopTimes") - @ExcludeMissing - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes - } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - @JsonProperty("timeZone") - @ExcludeMissing - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Schedule = - Schedule( - frequency, - nextTripId, - previousTripId, - stopTimes.map { it.toImmutable() }, - timeZone, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = StopTime.Builder::class) - @NoAutoDetect - class StopTime - private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - - fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) - - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = - Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime() = departureTime - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy - - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign - - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - 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 { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) - } - - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - @JsonProperty("departureTime") - @ExcludeMissing - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): StopTime = - StopTime( - arrivalTime, - departureTime, - distanceAlongTrip, - historicalOccupancy, - stopHeadsign, - stopId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schedule && this.frequency == other.frequency && this.nextTripId == other.nextTripId && this.previousTripId == other.previousTripId && this.stopTimes == other.stopTimes && this.timeZone == other.timeZone && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Status.Builder::class) - @NoAutoDetect - class Status - private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount() = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Status = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() - private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() - private var lastKnownLocation: JsonField = JsonMissing.of() - private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var nextStop: JsonField = JsonMissing.of() - private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() - private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(status: Status) = apply { - this.activeTripId = status.activeTripId - this.blockTripSequence = status.blockTripSequence - this.closestStop = status.closestStop - this.closestStopTimeOffset = status.closestStopTimeOffset - this.distanceAlongTrip = status.distanceAlongTrip - this.frequency = status.frequency - this.lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - this.lastKnownLocation = status.lastKnownLocation - this.lastKnownOrientation = status.lastKnownOrientation - this.lastLocationUpdateTime = status.lastLocationUpdateTime - this.lastUpdateTime = status.lastUpdateTime - this.nextStop = status.nextStop - this.nextStopTimeOffset = status.nextStopTimeOffset - this.occupancyCapacity = status.occupancyCapacity - this.occupancyCount = status.occupancyCount - this.occupancyStatus = status.occupancyStatus - this.orientation = status.orientation - this.phase = status.phase - this.position = status.position - this.predicted = status.predicted - this.scheduleDeviation = status.scheduleDeviation - this.scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - this.serviceDate = status.serviceDate - this.situationIds = status.situationIds - this.status = status.status - this.totalDistanceAlongTrip = status.totalDistanceAlongTrip - this.vehicleId = status.vehicleId - additionalProperties(status.additionalProperties) - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun activeTripId(activeTripId: JsonField) = apply { - this.activeTripId = activeTripId - } - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun closestStop(closestStop: JsonField) = apply { - this.closestStop = closestStop - } - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = - lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = - apply { - this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip - } - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun lastKnownLocation(lastKnownLocation: JsonField) = apply { - this.lastKnownLocation = lastKnownLocation - } - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: Double) = - lastKnownOrientation(JsonField.of(lastKnownOrientation)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: Long) = - nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing - fun phase(phase: JsonField) = apply { this.phase = phase } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - fun scheduleDeviation(scheduleDeviation: Long) = - scheduleDeviation(JsonField.of(scheduleDeviation)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun scheduleDeviation(scheduleDeviation: JsonField) = apply { - this.scheduleDeviation = scheduleDeviation - } - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { - this.totalDistanceAlongTrip = totalDistanceAlongTrip - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Status = - Status( - activeTripId, - blockTripSequence, - closestStop, - closestStopTimeOffset, - distanceAlongTrip, - frequency, - lastKnownDistanceAlongTrip, - lastKnownLocation, - lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, - nextStop, - nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, - orientation, - phase, - position, - predicted, - scheduleDeviation, - scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) - @NoAutoDetect - class LastKnownLocation - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) - } - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) - @NoAutoDetect - class Position - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) - } - - /** Latitude of the current position of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the current position of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.frequency == other.frequency && this.schedule == other.schedule && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, schedule, serviceDate, situationIds, status, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, tripId=$tripId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripForVehicleRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripForVehicleRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt deleted file mode 100644 index 76f1f30..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class TripRetrieveParams -constructor( - private val tripId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun tripId(): String = tripId - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> tripId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripRetrieveParams && this.tripId == other.tripId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(tripId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripRetrieveParams{tripId=$tripId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var tripId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(tripRetrieveParams: TripRetrieveParams) = apply { - this.tripId = tripRetrieveParams.tripId - additionalHeaders(tripRetrieveParams.additionalHeaders) - additionalQueryParams(tripRetrieveParams.additionalQueryParams) - } - - fun tripId(tripId: String) = apply { this.tripId = tripId } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): TripRetrieveParams = - TripRetrieveParams( - checkNotNull(tripId) { "`tripId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt deleted file mode 100644 index 4377e27..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt +++ /dev/null @@ -1,542 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = TripRetrieveResponse.Builder::class) -@NoAutoDetect -class TripRetrieveResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tripRetrieveResponse: TripRetrieveResponse) = apply { - this.code = tripRetrieveResponse.code - this.currentTime = tripRetrieveResponse.currentTime - this.text = tripRetrieveResponse.text - this.version = tripRetrieveResponse.version - this.data = tripRetrieveResponse.data - additionalProperties(tripRetrieveResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TripRetrieveResponse = - TripRetrieveResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - @JsonProperty("entry") - @ExcludeMissing - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - entry, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Entry.Builder::class) - @NoAutoDetect - class Entry - private constructor( - private val blockId: JsonField, - private val directionId: JsonField, - private val id: JsonField, - private val peakOffpeak: JsonField, - private val routeId: JsonField, - private val routeShortName: JsonField, - private val serviceId: JsonField, - private val shapeId: JsonField, - private val timeZone: JsonField, - private val tripHeadsign: JsonField, - private val tripShortName: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) - - fun directionId(): Optional = - Optional.ofNullable(directionId.getNullable("directionId")) - - fun id(): String = id.getRequired("id") - - fun peakOffpeak(): Optional = - Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - - fun routeId(): String = routeId.getRequired("routeId") - - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - fun serviceId(): String = serviceId.getRequired("serviceId") - - fun shapeId(): Optional = Optional.ofNullable(shapeId.getNullable("shapeId")) - - fun timeZone(): Optional = Optional.ofNullable(timeZone.getNullable("timeZone")) - - fun tripHeadsign(): Optional = - Optional.ofNullable(tripHeadsign.getNullable("tripHeadsign")) - - fun tripShortName(): Optional = - Optional.ofNullable(tripShortName.getNullable("tripShortName")) - - @JsonProperty("blockId") @ExcludeMissing fun _blockId() = blockId - - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("peakOffpeak") @ExcludeMissing fun _peakOffpeak() = peakOffpeak - - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - @JsonProperty("routeShortName") @ExcludeMissing fun _routeShortName() = routeShortName - - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId - - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId() = shapeId - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone - - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign - - @JsonProperty("tripShortName") @ExcludeMissing fun _tripShortName() = tripShortName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Entry = apply { - if (!validated) { - blockId() - directionId() - id() - peakOffpeak() - routeId() - routeShortName() - serviceId() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var blockId: JsonField = JsonMissing.of() - private var directionId: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var peakOffpeak: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() - private var routeShortName: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() - private var shapeId: JsonField = JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() - private var tripShortName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - this.blockId = entry.blockId - this.directionId = entry.directionId - this.id = entry.id - this.peakOffpeak = entry.peakOffpeak - this.routeId = entry.routeId - this.routeShortName = entry.routeShortName - this.serviceId = entry.serviceId - this.shapeId = entry.shapeId - this.timeZone = entry.timeZone - this.tripHeadsign = entry.tripHeadsign - this.tripShortName = entry.tripShortName - additionalProperties(entry.additionalProperties) - } - - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - - @JsonProperty("blockId") - @ExcludeMissing - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - - @JsonProperty("directionId") - @ExcludeMissing - fun directionId(directionId: JsonField) = apply { - this.directionId = directionId - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) - - @JsonProperty("peakOffpeak") - @ExcludeMissing - fun peakOffpeak(peakOffpeak: JsonField) = apply { - this.peakOffpeak = peakOffpeak - } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - @JsonProperty("routeId") - @ExcludeMissing - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun routeShortName(routeShortName: String) = - routeShortName(JsonField.of(routeShortName)) - - @JsonProperty("routeShortName") - @ExcludeMissing - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - @JsonProperty("serviceId") - @ExcludeMissing - fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } - - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) - - @JsonProperty("shapeId") - @ExcludeMissing - fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - @JsonProperty("timeZone") - @ExcludeMissing - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) - - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } - - fun tripShortName(tripShortName: String) = - tripShortName(JsonField.of(tripShortName)) - - @JsonProperty("tripShortName") - @ExcludeMissing - fun tripShortName(tripShortName: JsonField) = apply { - this.tripShortName = tripShortName - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Entry = - Entry( - blockId, - directionId, - id, - peakOffpeak, - routeId, - routeShortName, - serviceId, - shapeId, - timeZone, - tripHeadsign, - tripShortName, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && this.blockId == other.blockId && this.directionId == other.directionId && this.id == other.id && this.peakOffpeak == other.peakOffpeak && this.routeId == other.routeId && this.routeShortName == other.routeShortName && this.serviceId == other.serviceId && this.shapeId == other.shapeId && this.timeZone == other.timeZone && this.tripHeadsign == other.tripHeadsign && this.tripShortName == other.tripShortName && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Entry{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt deleted file mode 100644 index 3c39b79..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt +++ /dev/null @@ -1,226 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class TripsForLocationListParams -constructor( - private val lat: Double, - private val latSpan: Double, - private val lon: Double, - private val lonSpan: Double, - private val includeSchedule: Boolean?, - private val includeTrip: Boolean?, - private val time: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun lat(): Double = lat - - fun latSpan(): Double = latSpan - - fun lon(): Double = lon - - fun lonSpan(): Double = lonSpan - - fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) - - fun includeTrip(): Optional = Optional.ofNullable(includeTrip) - - fun time(): Optional = Optional.ofNullable(time) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.lat.let { params.put("lat", listOf(it.toString())) } - this.latSpan.let { params.put("latSpan", listOf(it.toString())) } - this.lon.let { params.put("lon", listOf(it.toString())) } - this.lonSpan.let { params.put("lonSpan", listOf(it.toString())) } - this.includeSchedule?.let { params.put("includeSchedule", listOf(it.toString())) } - this.includeTrip?.let { params.put("includeTrip", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsForLocationListParams && this.lat == other.lat && this.latSpan == other.latSpan && this.lon == other.lon && this.lonSpan == other.lonSpan && this.includeSchedule == other.includeSchedule && this.includeTrip == other.includeTrip && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(lat, latSpan, lon, lonSpan, includeSchedule, includeTrip, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripsForLocationListParams{lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, includeSchedule=$includeSchedule, includeTrip=$includeTrip, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var lat: Double? = null - private var latSpan: Double? = null - private var lon: Double? = null - private var lonSpan: Double? = null - private var includeSchedule: Boolean? = null - private var includeTrip: Boolean? = null - private var time: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(tripsForLocationListParams: TripsForLocationListParams) = apply { - this.lat = tripsForLocationListParams.lat - this.latSpan = tripsForLocationListParams.latSpan - this.lon = tripsForLocationListParams.lon - this.lonSpan = tripsForLocationListParams.lonSpan - this.includeSchedule = tripsForLocationListParams.includeSchedule - this.includeTrip = tripsForLocationListParams.includeTrip - this.time = tripsForLocationListParams.time - additionalHeaders(tripsForLocationListParams.additionalHeaders) - additionalQueryParams(tripsForLocationListParams.additionalQueryParams) - } - - /** The latitude coordinate of the search center */ - fun lat(lat: Double) = apply { this.lat = lat } - - /** Latitude span of the search bounding box */ - fun latSpan(latSpan: Double) = apply { this.latSpan = latSpan } - - /** The longitude coordinate of the search center */ - fun lon(lon: Double) = apply { this.lon = lon } - - /** Longitude span of the search bounding box */ - fun lonSpan(lonSpan: Double) = 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 - } - - /** Whether to include full trip elements in the references section. Defaults to false. */ - fun includeTrip(includeTrip: Boolean) = apply { this.includeTrip = includeTrip } - - /** Specific time for the query. Defaults to the current time. */ - fun time(time: Long) = apply { this.time = time } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): TripsForLocationListParams = - TripsForLocationListParams( - checkNotNull(lat) { "`lat` is required but was not set" }, - checkNotNull(latSpan) { "`latSpan` is required but was not set" }, - checkNotNull(lon) { "`lon` is required but was not set" }, - checkNotNull(lonSpan) { "`lonSpan` is required but was not set" }, - includeSchedule, - includeTrip, - time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt deleted file mode 100644 index 62bf5b0..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt +++ /dev/null @@ -1,1892 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = TripsForLocationListResponse.Builder::class) -@NoAutoDetect -class TripsForLocationListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripsForLocationListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tripsForLocationListResponse: TripsForLocationListResponse) = apply { - this.code = tripsForLocationListResponse.code - this.currentTime = tripsForLocationListResponse.currentTime - this.text = tripsForLocationListResponse.text - this.version = tripsForLocationListResponse.version - this.data = tripsForLocationListResponse.data - additionalProperties(tripsForLocationListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TripsForLocationListResponse = - TripsForLocationListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val outOfRange: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Indicates if the limit of trips has been exceeded */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - /** Indicates if the search location is out of range */ - fun outOfRange(): Optional = - Optional.ofNullable(outOfRange.getNullable("outOfRange")) - - fun references(): References = references.getRequired("references") - - /** Indicates if the limit of trips has been exceeded */ - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - /** Indicates if the search location is out of range */ - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.outOfRange = data.outOfRange - this.references = data.references - additionalProperties(data.additionalProperties) - } - - /** Indicates if the limit of trips has been exceeded */ - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** Indicates if the limit of trips has been exceeded */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - /** Indicates if the search location is out of range */ - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - /** Indicates if the search location is out of range */ - @JsonProperty("outOfRange") - @ExcludeMissing - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - outOfRange, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val frequency: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val tripId: JsonField, - private val schedule: JsonField, - private val status: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun serviceDate(): Optional = - Optional.ofNullable(serviceDate.getNullable("serviceDate")) - - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - fun tripId(): String = tripId.getRequired("tripId") - - fun schedule(): Schedule = schedule.getRequired("schedule") - - fun status(): Status = status.getRequired("status") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonProperty("schedule") @ExcludeMissing fun _schedule() = schedule - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - frequency() - serviceDate() - situationIds() - tripId() - schedule().validate() - status().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var frequency: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.frequency = list.frequency - this.serviceDate = list.serviceDate - this.situationIds = list.situationIds - this.tripId = list.tripId - this.schedule = list.schedule - this.status = list.status - additionalProperties(list.additionalProperties) - } - - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - @JsonProperty("schedule") - @ExcludeMissing - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - frequency, - serviceDate, - situationIds.map { it.toImmutable() }, - tripId, - schedule, - status, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Schedule.Builder::class) - @NoAutoDetect - class Schedule - private constructor( - private val frequency: JsonField, - private val nextTripId: JsonField, - private val previousTripId: JsonField, - private val stopTimes: JsonField>, - private val timeZone: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun nextTripId(): String = nextTripId.getRequired("nextTripId") - - fun previousTripId(): String = previousTripId.getRequired("previousTripId") - - fun stopTimes(): kotlin.collections.List = - stopTimes.getRequired("stopTimes") - - fun timeZone(): String = timeZone.getRequired("timeZone") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - @JsonProperty("nextTripId") @ExcludeMissing fun _nextTripId() = nextTripId - - @JsonProperty("previousTripId") - @ExcludeMissing - fun _previousTripId() = previousTripId - - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Schedule = apply { - if (!validated) { - frequency() - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField = JsonMissing.of() - private var previousTripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = - JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - this.frequency = schedule.frequency - this.nextTripId = schedule.nextTripId - this.previousTripId = schedule.previousTripId - this.stopTimes = schedule.stopTimes - this.timeZone = schedule.timeZone - additionalProperties(schedule.additionalProperties) - } - - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - - @JsonProperty("nextTripId") - @ExcludeMissing - fun nextTripId(nextTripId: JsonField) = apply { - this.nextTripId = nextTripId - } - - fun previousTripId(previousTripId: String) = - previousTripId(JsonField.of(previousTripId)) - - @JsonProperty("previousTripId") - @ExcludeMissing - fun previousTripId(previousTripId: JsonField) = apply { - this.previousTripId = previousTripId - } - - fun stopTimes(stopTimes: kotlin.collections.List) = - stopTimes(JsonField.of(stopTimes)) - - @JsonProperty("stopTimes") - @ExcludeMissing - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes - } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - @JsonProperty("timeZone") - @ExcludeMissing - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Schedule = - Schedule( - frequency, - nextTripId, - previousTripId, - stopTimes.map { it.toImmutable() }, - timeZone, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = StopTime.Builder::class) - @NoAutoDetect - class StopTime - private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - - fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) - - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = - Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime() = departureTime - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy - - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign - - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - 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 { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) - } - - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - @JsonProperty("departureTime") - @ExcludeMissing - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): StopTime = - StopTime( - arrivalTime, - departureTime, - distanceAlongTrip, - historicalOccupancy, - stopHeadsign, - stopId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schedule && this.frequency == other.frequency && this.nextTripId == other.nextTripId && this.previousTripId == other.previousTripId && this.stopTimes == other.stopTimes && this.timeZone == other.timeZone && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Status.Builder::class) - @NoAutoDetect - class Status - private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount() = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Status = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() - private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() - private var lastKnownLocation: JsonField = JsonMissing.of() - private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var nextStop: JsonField = JsonMissing.of() - private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() - private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(status: Status) = apply { - this.activeTripId = status.activeTripId - this.blockTripSequence = status.blockTripSequence - this.closestStop = status.closestStop - this.closestStopTimeOffset = status.closestStopTimeOffset - this.distanceAlongTrip = status.distanceAlongTrip - this.frequency = status.frequency - this.lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - this.lastKnownLocation = status.lastKnownLocation - this.lastKnownOrientation = status.lastKnownOrientation - this.lastLocationUpdateTime = status.lastLocationUpdateTime - this.lastUpdateTime = status.lastUpdateTime - this.nextStop = status.nextStop - this.nextStopTimeOffset = status.nextStopTimeOffset - this.occupancyCapacity = status.occupancyCapacity - this.occupancyCount = status.occupancyCount - this.occupancyStatus = status.occupancyStatus - this.orientation = status.orientation - this.phase = status.phase - this.position = status.position - this.predicted = status.predicted - this.scheduleDeviation = status.scheduleDeviation - this.scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - this.serviceDate = status.serviceDate - this.situationIds = status.situationIds - this.status = status.status - this.totalDistanceAlongTrip = status.totalDistanceAlongTrip - this.vehicleId = status.vehicleId - additionalProperties(status.additionalProperties) - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun activeTripId(activeTripId: JsonField) = apply { - this.activeTripId = activeTripId - } - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun closestStop(closestStop: JsonField) = apply { - this.closestStop = closestStop - } - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = - lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = - apply { - this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip - } - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun lastKnownLocation(lastKnownLocation: JsonField) = apply { - this.lastKnownLocation = lastKnownLocation - } - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: Double) = - lastKnownOrientation(JsonField.of(lastKnownOrientation)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: Long) = - nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing - fun phase(phase: JsonField) = apply { this.phase = phase } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - fun scheduleDeviation(scheduleDeviation: Long) = - scheduleDeviation(JsonField.of(scheduleDeviation)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun scheduleDeviation(scheduleDeviation: JsonField) = apply { - this.scheduleDeviation = scheduleDeviation - } - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = - apply { - this.situationIds = situationIds - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { - this.totalDistanceAlongTrip = totalDistanceAlongTrip - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Status = - Status( - activeTripId, - blockTripSequence, - closestStop, - closestStopTimeOffset, - distanceAlongTrip, - frequency, - lastKnownDistanceAlongTrip, - lastKnownLocation, - lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, - nextStop, - nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, - orientation, - phase, - position, - predicted, - scheduleDeviation, - scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) - @NoAutoDetect - class LastKnownLocation - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) - } - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) - @NoAutoDetect - class Position - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) - } - - /** Latitude of the current position of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the current position of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.frequency == other.frequency && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.tripId == other.tripId && this.schedule == other.schedule && this.status == other.status && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, serviceDate, situationIds, tripId, schedule, status, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, tripId=$tripId, schedule=$schedule, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.outOfRange == other.outOfRange && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsForLocationListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripsForLocationListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt deleted file mode 100644 index 2e87437..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt +++ /dev/null @@ -1,202 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class TripsForRouteListParams -constructor( - private val routeId: String, - private val includeSchedule: Boolean?, - private val includeStatus: Boolean?, - private val time: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun routeId(): String = routeId - - fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) - - fun includeStatus(): Optional = Optional.ofNullable(includeStatus) - - fun time(): Optional = Optional.ofNullable(time) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.includeSchedule?.let { params.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { params.put("includeStatus", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> routeId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsForRouteListParams && this.routeId == other.routeId && this.includeSchedule == other.includeSchedule && this.includeStatus == other.includeStatus && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(routeId, includeSchedule, includeStatus, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripsForRouteListParams{routeId=$routeId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var routeId: String? = null - private var includeSchedule: Boolean? = null - private var includeStatus: Boolean? = null - private var time: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(tripsForRouteListParams: TripsForRouteListParams) = apply { - this.routeId = tripsForRouteListParams.routeId - this.includeSchedule = tripsForRouteListParams.includeSchedule - this.includeStatus = tripsForRouteListParams.includeStatus - this.time = tripsForRouteListParams.time - additionalHeaders(tripsForRouteListParams.additionalHeaders) - additionalQueryParams(tripsForRouteListParams.additionalQueryParams) - } - - fun routeId(routeId: String) = apply { this.routeId = routeId } - - /** Determine whether full schedule elements are included. Defaults to false. */ - fun includeSchedule(includeSchedule: Boolean) = apply { - this.includeSchedule = includeSchedule - } - - /** - * Determine whether full tripStatus elements with real-time information are included. - * Defaults to false. - */ - fun includeStatus(includeStatus: Boolean) = apply { this.includeStatus = includeStatus } - - /** Query the system at a specific time. Useful for testing. */ - fun time(time: Long) = apply { this.time = time } - - 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): TripsForRouteListParams = - TripsForRouteListParams( - checkNotNull(routeId) { "`routeId` is required but was not set" }, - includeSchedule, - includeStatus, - time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt deleted file mode 100644 index e048b4e..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt +++ /dev/null @@ -1,1868 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = TripsForRouteListResponse.Builder::class) -@NoAutoDetect -class TripsForRouteListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripsForRouteListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tripsForRouteListResponse: TripsForRouteListResponse) = apply { - this.code = tripsForRouteListResponse.code - this.currentTime = tripsForRouteListResponse.currentTime - this.text = tripsForRouteListResponse.text - this.version = tripsForRouteListResponse.version - this.data = tripsForRouteListResponse.data - additionalProperties(tripsForRouteListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TripsForRouteListResponse = - TripsForRouteListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - limitExceeded, - list.map { it.toImmutable() }, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val frequency: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val tripId: JsonField, - private val schedule: JsonField, - private val status: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun serviceDate(): Optional = - Optional.ofNullable(serviceDate.getNullable("serviceDate")) - - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - fun tripId(): String = tripId.getRequired("tripId") - - fun schedule(): Schedule = schedule.getRequired("schedule") - - fun status(): Status = status.getRequired("status") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonProperty("schedule") @ExcludeMissing fun _schedule() = schedule - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - frequency() - serviceDate() - situationIds() - tripId() - schedule().validate() - status().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var frequency: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - this.frequency = list.frequency - this.serviceDate = list.serviceDate - this.situationIds = list.situationIds - this.tripId = list.tripId - this.schedule = list.schedule - this.status = list.status - additionalProperties(list.additionalProperties) - } - - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - @JsonProperty("schedule") - @ExcludeMissing - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - frequency, - serviceDate, - situationIds.map { it.toImmutable() }, - tripId, - schedule, - status, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Schedule.Builder::class) - @NoAutoDetect - class Schedule - private constructor( - private val frequency: JsonField, - private val nextTripId: JsonField, - private val previousTripId: JsonField, - private val stopTimes: JsonField>, - private val timeZone: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun nextTripId(): String = nextTripId.getRequired("nextTripId") - - fun previousTripId(): String = previousTripId.getRequired("previousTripId") - - fun stopTimes(): kotlin.collections.List = - stopTimes.getRequired("stopTimes") - - fun timeZone(): String = timeZone.getRequired("timeZone") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - @JsonProperty("nextTripId") @ExcludeMissing fun _nextTripId() = nextTripId - - @JsonProperty("previousTripId") - @ExcludeMissing - fun _previousTripId() = previousTripId - - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Schedule = apply { - if (!validated) { - frequency() - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField = JsonMissing.of() - private var previousTripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = - JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - this.frequency = schedule.frequency - this.nextTripId = schedule.nextTripId - this.previousTripId = schedule.previousTripId - this.stopTimes = schedule.stopTimes - this.timeZone = schedule.timeZone - additionalProperties(schedule.additionalProperties) - } - - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - - @JsonProperty("nextTripId") - @ExcludeMissing - fun nextTripId(nextTripId: JsonField) = apply { - this.nextTripId = nextTripId - } - - fun previousTripId(previousTripId: String) = - previousTripId(JsonField.of(previousTripId)) - - @JsonProperty("previousTripId") - @ExcludeMissing - fun previousTripId(previousTripId: JsonField) = apply { - this.previousTripId = previousTripId - } - - fun stopTimes(stopTimes: kotlin.collections.List) = - stopTimes(JsonField.of(stopTimes)) - - @JsonProperty("stopTimes") - @ExcludeMissing - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes - } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - @JsonProperty("timeZone") - @ExcludeMissing - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Schedule = - Schedule( - frequency, - nextTripId, - previousTripId, - stopTimes.map { it.toImmutable() }, - timeZone, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = StopTime.Builder::class) - @NoAutoDetect - class StopTime - private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - - fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) - - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = - Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime() = departureTime - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy - - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign - - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - 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 { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) - } - - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - @JsonProperty("departureTime") - @ExcludeMissing - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - @JsonProperty("stopId") - @ExcludeMissing - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): StopTime = - StopTime( - arrivalTime, - departureTime, - distanceAlongTrip, - historicalOccupancy, - stopHeadsign, - stopId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schedule && this.frequency == other.frequency && this.nextTripId == other.nextTripId && this.previousTripId == other.previousTripId && this.stopTimes == other.stopTimes && this.timeZone == other.timeZone && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Status.Builder::class) - @NoAutoDetect - class Status - private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount() = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Status = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() - private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() - private var lastKnownLocation: JsonField = JsonMissing.of() - private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var nextStop: JsonField = JsonMissing.of() - private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() - private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(status: Status) = apply { - this.activeTripId = status.activeTripId - this.blockTripSequence = status.blockTripSequence - this.closestStop = status.closestStop - this.closestStopTimeOffset = status.closestStopTimeOffset - this.distanceAlongTrip = status.distanceAlongTrip - this.frequency = status.frequency - this.lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - this.lastKnownLocation = status.lastKnownLocation - this.lastKnownOrientation = status.lastKnownOrientation - this.lastLocationUpdateTime = status.lastLocationUpdateTime - this.lastUpdateTime = status.lastUpdateTime - this.nextStop = status.nextStop - this.nextStopTimeOffset = status.nextStopTimeOffset - this.occupancyCapacity = status.occupancyCapacity - this.occupancyCount = status.occupancyCount - this.occupancyStatus = status.occupancyStatus - this.orientation = status.orientation - this.phase = status.phase - this.position = status.position - this.predicted = status.predicted - this.scheduleDeviation = status.scheduleDeviation - this.scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - this.serviceDate = status.serviceDate - this.situationIds = status.situationIds - this.status = status.status - this.totalDistanceAlongTrip = status.totalDistanceAlongTrip - this.vehicleId = status.vehicleId - additionalProperties(status.additionalProperties) - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun activeTripId(activeTripId: JsonField) = apply { - this.activeTripId = activeTripId - } - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun closestStop(closestStop: JsonField) = apply { - this.closestStop = closestStop - } - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = - lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = - apply { - this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip - } - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun lastKnownLocation(lastKnownLocation: JsonField) = apply { - this.lastKnownLocation = lastKnownLocation - } - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: Double) = - lastKnownOrientation(JsonField.of(lastKnownOrientation)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: Long) = - nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing - fun phase(phase: JsonField) = apply { this.phase = phase } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - fun scheduleDeviation(scheduleDeviation: Long) = - scheduleDeviation(JsonField.of(scheduleDeviation)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun scheduleDeviation(scheduleDeviation: JsonField) = apply { - this.scheduleDeviation = scheduleDeviation - } - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = - apply { - this.situationIds = situationIds - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { - this.totalDistanceAlongTrip = totalDistanceAlongTrip - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Status = - Status( - activeTripId, - blockTripSequence, - closestStop, - closestStopTimeOffset, - distanceAlongTrip, - frequency, - lastKnownDistanceAlongTrip, - lastKnownLocation, - lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, - nextStop, - nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, - orientation, - phase, - position, - predicted, - scheduleDeviation, - scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) - @NoAutoDetect - class LastKnownLocation - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) - } - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) - @NoAutoDetect - class Position - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) - } - - /** Latitude of the current position of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the current position of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.frequency == other.frequency && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.tripId == other.tripId && this.schedule == other.schedule && this.status == other.status && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, serviceDate, situationIds, tripId, schedule, status, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, tripId=$tripId, schedule=$schedule, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsForRouteListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripsForRouteListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt deleted file mode 100644 index 0fccd78..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt +++ /dev/null @@ -1,177 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable -import org.onebusaway.models.* - -class VehiclesForAgencyListParams -constructor( - private val agencyId: String, - private val time: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, -) { - - fun agencyId(): String = agencyId - - fun time(): Optional = Optional.ofNullable(time) - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VehiclesForAgencyListParams && this.agencyId == other.agencyId && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "VehiclesForAgencyListParams{agencyId=$agencyId, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var agencyId: String? = null - private var time: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() - - @JvmSynthetic - internal fun from(vehiclesForAgencyListParams: VehiclesForAgencyListParams) = apply { - this.agencyId = vehiclesForAgencyListParams.agencyId - this.time = vehiclesForAgencyListParams.time - additionalHeaders(vehiclesForAgencyListParams.additionalHeaders) - additionalQueryParams(vehiclesForAgencyListParams.additionalQueryParams) - } - - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } - - /** Specific time for querying the status (timestamp format) */ - fun time(time: String) = apply { this.time = time } - - fun 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.putAll(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) - } - - 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.putAll(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) - } - - fun build(): VehiclesForAgencyListParams = - VehiclesForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - ) - } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt deleted file mode 100644 index 6adbe4f..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt +++ /dev/null @@ -1,1707 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable - -@JsonDeserialize(builder = VehiclesForAgencyListResponse.Builder::class) -@NoAutoDetect -class VehiclesForAgencyListResponse -private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - @JsonProperty("code") @ExcludeMissing fun _code() = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): VehiclesForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(vehiclesForAgencyListResponse: VehiclesForAgencyListResponse) = apply { - this.code = vehiclesForAgencyListResponse.code - this.currentTime = vehiclesForAgencyListResponse.currentTime - this.text = vehiclesForAgencyListResponse.text - this.version = vehiclesForAgencyListResponse.version - this.data = vehiclesForAgencyListResponse.data - additionalProperties(vehiclesForAgencyListResponse.additionalProperties) - } - - fun code(code: Long) = code(JsonField.of(code)) - - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - @JsonProperty("currentTime") - @ExcludeMissing - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): VehiclesForAgencyListResponse = - VehiclesForAgencyListResponse( - code, - currentTime, - text, - version, - data, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val list: JsonField>, - private val limitExceeded: JsonField, - private val references: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun references(): References = references.getRequired("references") - - @JsonProperty("list") @ExcludeMissing fun _list() = list - - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded - - @JsonProperty("references") @ExcludeMissing fun _references() = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - list().forEach { it.validate() } - limitExceeded() - references().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var list: JsonField> = JsonMissing.of() - private var limitExceeded: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - this.list = data.list - this.limitExceeded = data.limitExceeded - this.references = data.references - additionalProperties(data.additionalProperties) - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - @JsonProperty("list") - @ExcludeMissing - fun list(list: JsonField>) = apply { this.list = list } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun references(references: References) = references(JsonField.of(references)) - - @JsonProperty("references") - @ExcludeMissing - fun references(references: JsonField) = apply { - this.references = references - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - list.map { it.toImmutable() }, - limitExceeded, - references, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = List.Builder::class) - @NoAutoDetect - class List - private constructor( - private val vehicleId: JsonField, - private val lastUpdateTime: JsonField, - private val lastLocationUpdateTime: JsonField, - private val location: JsonField, - private val tripId: JsonField, - private val tripStatus: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val phase: JsonField, - private val status: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - fun location(): Location = location.getRequired("location") - - fun tripId(): String = tripId.getRequired("tripId") - - fun tripStatus(): TripStatus = tripStatus.getRequired("tripStatus") - - fun occupancyCapacity(): Optional = - Optional.ofNullable(occupancyCapacity.getNullable("occupancyCapacity")) - - fun occupancyCount(): Optional = - Optional.ofNullable(occupancyCount.getNullable("occupancyCount")) - - fun occupancyStatus(): Optional = - Optional.ofNullable(occupancyStatus.getNullable("occupancyStatus")) - - fun phase(): Optional = Optional.ofNullable(phase.getNullable("phase")) - - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonProperty("lastUpdateTime") @ExcludeMissing fun _lastUpdateTime() = lastUpdateTime - - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime - - @JsonProperty("location") @ExcludeMissing fun _location() = location - - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - @JsonProperty("tripStatus") @ExcludeMissing fun _tripStatus() = tripStatus - - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity - - @JsonProperty("occupancyCount") @ExcludeMissing fun _occupancyCount() = occupancyCount - - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): List = apply { - if (!validated) { - vehicleId() - lastUpdateTime() - lastLocationUpdateTime() - location().validate() - tripId() - tripStatus().validate() - occupancyCapacity() - occupancyCount() - occupancyStatus() - phase() - status() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var vehicleId: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var tripStatus: JsonField = JsonMissing.of() - private var 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 { - this.vehicleId = list.vehicleId - this.lastUpdateTime = list.lastUpdateTime - this.lastLocationUpdateTime = list.lastLocationUpdateTime - this.location = list.location - this.tripId = list.tripId - this.tripStatus = list.tripStatus - this.occupancyCapacity = list.occupancyCapacity - this.occupancyCount = list.occupancyCount - this.occupancyStatus = list.occupancyStatus - this.phase = list.phase - this.status = list.status - additionalProperties(list.additionalProperties) - } - - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } - - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - fun location(location: Location) = location(JsonField.of(location)) - - @JsonProperty("location") - @ExcludeMissing - fun location(location: JsonField) = apply { this.location = location } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - @JsonProperty("tripId") - @ExcludeMissing - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) - - @JsonProperty("tripStatus") - @ExcludeMissing - fun tripStatus(tripStatus: JsonField) = apply { - this.tripStatus = tripStatus - } - - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - @JsonProperty("occupancyCount") - @ExcludeMissing - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - fun phase(phase: String) = phase(JsonField.of(phase)) - - @JsonProperty("phase") - @ExcludeMissing - fun phase(phase: JsonField) = apply { this.phase = phase } - - fun status(status: String) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): List = - List( - vehicleId, - lastUpdateTime, - lastLocationUpdateTime, - location, - tripId, - tripStatus, - occupancyCapacity, - occupancyCount, - occupancyStatus, - phase, - status, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Location.Builder::class) - @NoAutoDetect - class Location - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Location = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(location: Location) = apply { - this.lat = location.lat - this.lon = location.lon - additionalProperties(location.additionalProperties) - } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Location = - Location( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Location && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Location{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = TripStatus.Builder::class) - @NoAutoDetect - class TripStatus - private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount() = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TripStatus = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() - private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() - private var lastKnownLocation: JsonField = JsonMissing.of() - private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var nextStop: JsonField = JsonMissing.of() - private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() - private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() - private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tripStatus: TripStatus) = apply { - this.activeTripId = tripStatus.activeTripId - this.blockTripSequence = tripStatus.blockTripSequence - this.closestStop = tripStatus.closestStop - this.closestStopTimeOffset = tripStatus.closestStopTimeOffset - this.distanceAlongTrip = tripStatus.distanceAlongTrip - this.frequency = tripStatus.frequency - this.lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - this.lastKnownLocation = tripStatus.lastKnownLocation - this.lastKnownOrientation = tripStatus.lastKnownOrientation - this.lastLocationUpdateTime = tripStatus.lastLocationUpdateTime - this.lastUpdateTime = tripStatus.lastUpdateTime - this.nextStop = tripStatus.nextStop - this.nextStopTimeOffset = tripStatus.nextStopTimeOffset - this.occupancyCapacity = tripStatus.occupancyCapacity - this.occupancyCount = tripStatus.occupancyCount - this.occupancyStatus = tripStatus.occupancyStatus - this.orientation = tripStatus.orientation - this.phase = tripStatus.phase - this.position = tripStatus.position - this.predicted = tripStatus.predicted - this.scheduleDeviation = tripStatus.scheduleDeviation - this.scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip - this.serviceDate = tripStatus.serviceDate - this.situationIds = tripStatus.situationIds - this.status = tripStatus.status - this.totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip - this.vehicleId = tripStatus.vehicleId - additionalProperties(tripStatus.additionalProperties) - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun activeTripId(activeTripId: JsonField) = apply { - this.activeTripId = activeTripId - } - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence - } - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun closestStop(closestStop: JsonField) = apply { - this.closestStop = closestStop - } - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = - lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = - apply { - this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip - } - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun lastKnownLocation(lastKnownLocation: JsonField) = apply { - this.lastKnownLocation = lastKnownLocation - } - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: Double) = - lastKnownOrientation(JsonField.of(lastKnownOrientation)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: Long) = - nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing - fun phase(phase: JsonField) = apply { this.phase = phase } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - fun scheduleDeviation(scheduleDeviation: Long) = - scheduleDeviation(JsonField.of(scheduleDeviation)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun scheduleDeviation(scheduleDeviation: JsonField) = apply { - this.scheduleDeviation = scheduleDeviation - } - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun situationIds(situationIds: JsonField>) = - apply { - this.situationIds = situationIds - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { - this.totalDistanceAlongTrip = totalDistanceAlongTrip - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TripStatus = - TripStatus( - activeTripId, - blockTripSequence, - closestStop, - closestStopTimeOffset, - distanceAlongTrip, - frequency, - lastKnownDistanceAlongTrip, - lastKnownLocation, - lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, - nextStop, - nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, - orientation, - phase, - position, - predicted, - scheduleDeviation, - scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) - @NoAutoDetect - class LastKnownLocation - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) - } - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) - @NoAutoDetect - class Position - private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var lat: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) - } - - /** Latitude of the current position of the transit vehicle. */ - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** Longitude of the current position of the transit vehicle. */ - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripStatus && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && this.vehicleId == other.vehicleId && this.lastUpdateTime == other.lastUpdateTime && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.location == other.location && this.tripId == other.tripId && this.tripStatus == other.tripStatus && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.phase == other.phase && this.status == other.status && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(vehicleId, lastUpdateTime, lastLocationUpdateTime, location, tripId, tripStatus, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "List{vehicleId=$vehicleId, lastUpdateTime=$lastUpdateTime, lastLocationUpdateTime=$lastLocationUpdateTime, location=$location, tripId=$tripId, tripStatus=$tripStatus, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && this.list == other.list && this.limitExceeded == other.limitExceeded && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(list, limitExceeded, references, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Data{list=$list, limitExceeded=$limitExceeded, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VehiclesForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "VehiclesForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParams.kt new file mode 100644 index 0000000..be2370c --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParams.kt @@ -0,0 +1,172 @@ +// 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 { + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is AgenciesWithCoverageListParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AgenciesWithCoverageListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt new file mode 100644 index 0000000..a0ae167 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt @@ -0,0 +1,876 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agencieswithcoverage + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class AgenciesWithCoverageListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AgenciesWithCoverageListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgenciesWithCoverageListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agenciesWithCoverageListResponse: AgenciesWithCoverageListResponse) = + apply { + code = agenciesWithCoverageListResponse.code + currentTime = agenciesWithCoverageListResponse.currentTime + text = agenciesWithCoverageListResponse.text + version = agenciesWithCoverageListResponse.version + data = agenciesWithCoverageListResponse.data + additionalProperties = + agenciesWithCoverageListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AgenciesWithCoverageListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgenciesWithCoverageListResponse = + AgenciesWithCoverageListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AgenciesWithCoverageListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val agencyId: JsonField, + private val lat: JsonField, + private val latSpan: JsonField, + private val lon: JsonField, + private val lonSpan: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("latSpan") + @ExcludeMissing + latSpan: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("lonSpan") + @ExcludeMissing + lonSpan: JsonField = JsonMissing.of(), + ) : this(agencyId, lat, latSpan, lon, lonSpan, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Double = lat.getRequired("lat") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun latSpan(): Double = latSpan.getRequired("latSpan") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Double = lon.getRequired("lon") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lonSpan(): Double = lonSpan.getRequired("lonSpan") + + /** + * Returns the raw JSON value of [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [latSpan]. + * + * Unlike [latSpan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latSpan") @ExcludeMissing fun _latSpan(): JsonField = latSpan + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + /** + * Returns the raw JSON value of [lonSpan]. + * + * Unlike [lonSpan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lonSpan") @ExcludeMissing fun _lonSpan(): JsonField = lonSpan + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .agencyId() + * .lat() + * .latSpan() + * .lon() + * .lonSpan() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var agencyId: JsonField? = null + private var lat: JsonField? = null + private var latSpan: JsonField? = null + private var lon: JsonField? = null + private var lonSpan: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + agencyId = list.agencyId + lat = list.lat + latSpan = list.latSpan + lon = list.lon + lonSpan = list.lonSpan + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + fun latSpan(latSpan: Double) = latSpan(JsonField.of(latSpan)) + + /** + * Sets [Builder.latSpan] to an arbitrary JSON value. + * + * You should usually call [Builder.latSpan] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun latSpan(latSpan: JsonField) = apply { this.latSpan = latSpan } + + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun lonSpan(lonSpan: Double) = lonSpan(JsonField.of(lonSpan)) + + /** + * Sets [Builder.lonSpan] to an arbitrary JSON value. + * + * You should usually call [Builder.lonSpan] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lonSpan(lonSpan: JsonField) = apply { this.lonSpan = lonSpan } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agencyId() + * .lat() + * .latSpan() + * .lon() + * .lonSpan() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("agencyId", agencyId), + checkRequired("lat", lat), + checkRequired("latSpan", latSpan), + checkRequired("lon", lon), + checkRequired("lonSpan", lonSpan), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + agencyId() + lat() + latSpan() + lon() + lonSpan() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (agencyId.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (latSpan.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (lonSpan.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && agencyId == other.agencyId && lat == other.lat && latSpan == other.latSpan && lon == other.lon && lonSpan == other.lonSpan && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, lat, latSpan, lon, lonSpan, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{agencyId=$agencyId, lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AgenciesWithCoverageListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgenciesWithCoverageListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveParams.kt new file mode 100644 index 0000000..e36ef5a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveParams.kt @@ -0,0 +1,184 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is AgencyRetrieveParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AgencyRetrieveParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt new file mode 100644 index 0000000..7211fe4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt @@ -0,0 +1,1031 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agency + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class AgencyRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AgencyRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgencyRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agencyRetrieveResponse: AgencyRetrieveResponse) = apply { + code = agencyRetrieveResponse.code + currentTime = agencyRetrieveResponse.currentTime + text = agencyRetrieveResponse.text + version = agencyRetrieveResponse.version + data = agencyRetrieveResponse.data + additionalProperties = agencyRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AgencyRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgencyRetrieveResponse = + AgencyRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AgencyRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val limitExceeded: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, limitExceeded, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .limitExceeded() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var limitExceeded: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + limitExceeded = data.limitExceeded + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .limitExceeded() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("limitExceeded", limitExceeded), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + limitExceeded() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val id: JsonField, + private val name: JsonField, + private val timezone: JsonField, + private val url: JsonField, + private val disclaimer: JsonField, + private val email: JsonField, + private val fareUrl: JsonField, + private val lang: JsonField, + private val phone: JsonField, + private val privateService: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + timezone: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("disclaimer") + @ExcludeMissing + disclaimer: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("fareUrl") + @ExcludeMissing + fareUrl: JsonField = JsonMissing.of(), + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("phone") @ExcludeMissing phone: JsonField = JsonMissing.of(), + @JsonProperty("privateService") + @ExcludeMissing + privateService: JsonField = JsonMissing.of(), + ) : this( + id, + name, + timezone, + url, + disclaimer, + email, + fareUrl, + lang, + phone, + privateService, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun timezone(): String = timezone.getRequired("timezone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun disclaimer(): Optional = disclaimer.getOptional("disclaimer") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun fareUrl(): Optional = fareUrl.getOptional("fareUrl") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun phone(): Optional = phone.getOptional("phone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun privateService(): Optional = privateService.getOptional("privateService") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [disclaimer]. + * + * Unlike [disclaimer], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("disclaimer") + @ExcludeMissing + fun _disclaimer(): JsonField = disclaimer + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [fareUrl]. + * + * Unlike [fareUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl(): JsonField = fareUrl + + /** + * Returns the raw JSON value of [lang]. + * + * Unlike [lang], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang + + /** + * Returns the raw JSON value of [phone]. + * + * Unlike [phone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone + + /** + * Returns the raw JSON value of [privateService]. + * + * Unlike [privateService], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("privateService") + @ExcludeMissing + fun _privateService(): JsonField = privateService + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .timezone() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var timezone: JsonField? = null + private var url: JsonField? = null + private var disclaimer: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var fareUrl: JsonField = JsonMissing.of() + private var lang: JsonField = JsonMissing.of() + private var phone: JsonField = JsonMissing.of() + private var privateService: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + name = entry.name + timezone = entry.timezone + url = entry.url + disclaimer = entry.disclaimer + email = entry.email + fareUrl = entry.fareUrl + lang = entry.lang + phone = entry.phone + privateService = entry.privateService + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * Sets [Builder.timezone] to an arbitrary JSON value. + * + * You should usually call [Builder.timezone] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) + + /** + * Sets [Builder.disclaimer] to an arbitrary JSON value. + * + * You should usually call [Builder.disclaimer] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun disclaimer(disclaimer: JsonField) = apply { + this.disclaimer = disclaimer + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun fareUrl(fareUrl: String) = fareUrl(JsonField.of(fareUrl)) + + /** + * Sets [Builder.fareUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.fareUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } + + fun lang(lang: String) = lang(JsonField.of(lang)) + + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lang(lang: JsonField) = apply { this.lang = lang } + + fun phone(phone: String) = phone(JsonField.of(phone)) + + /** + * Sets [Builder.phone] to an arbitrary JSON value. + * + * You should usually call [Builder.phone] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phone(phone: JsonField) = apply { this.phone = phone } + + fun privateService(privateService: Boolean) = + privateService(JsonField.of(privateService)) + + /** + * Sets [Builder.privateService] to an arbitrary JSON value. + * + * You should usually call [Builder.privateService] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun privateService(privateService: JsonField) = apply { + this.privateService = privateService + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .timezone() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("timezone", timezone), + checkRequired("url", url), + disclaimer, + email, + fareUrl, + lang, + phone, + privateService, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + name() + timezone() + url() + disclaimer() + email() + fareUrl() + lang() + phone() + privateService() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (disclaimer.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (fareUrl.asKnown().isPresent) 1 else 0) + + (if (lang.asKnown().isPresent) 1 else 0) + + (if (phone.asKnown().isPresent) 1 else 0) + + (if (privateService.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && name == other.name && timezone == other.timezone && url == other.url && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && lang == other.lang && phone == other.phone && privateService == other.privateService && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, timezone, url, disclaimer, email, fareUrl, lang, phone, privateService, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, name=$name, timezone=$timezone, url=$url, disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, lang=$lang, phone=$phone, privateService=$privateService, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && limitExceeded == other.limitExceeded && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, limitExceeded, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, limitExceeded=$limitExceeded, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AgencyRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgencyRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParams.kt new file mode 100644 index 0000000..8a09c9b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParams.kt @@ -0,0 +1,254 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is ArrivalAndDepartureListParams && stopId == other.stopId && minutesAfter == other.minutesAfter && minutesBefore == other.minutesBefore && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, minutesAfter, minutesBefore, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ArrivalAndDepartureListParams{stopId=$stopId, minutesAfter=$minutesAfter, minutesBefore=$minutesBefore, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt new file mode 100644 index 0000000..7ffbe8f --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt @@ -0,0 +1,4174 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class ArrivalAndDepartureListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalAndDepartureListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalAndDepartureListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(arrivalAndDepartureListResponse: ArrivalAndDepartureListResponse) = + apply { + code = arrivalAndDepartureListResponse.code + currentTime = arrivalAndDepartureListResponse.currentTime + text = arrivalAndDepartureListResponse.text + version = arrivalAndDepartureListResponse.version + data = arrivalAndDepartureListResponse.data + additionalProperties = + arrivalAndDepartureListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ArrivalAndDepartureListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArrivalAndDepartureListResponse = + ArrivalAndDepartureListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ArrivalAndDepartureListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val arrivalsAndDepartures: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalsAndDepartures") + @ExcludeMissing + arrivalsAndDepartures: JsonField> = JsonMissing.of() + ) : this(arrivalsAndDepartures, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun arrivalsAndDepartures(): List = + arrivalsAndDepartures.getRequired("arrivalsAndDepartures") + + /** + * Returns the raw JSON value of [arrivalsAndDepartures]. + * + * Unlike [arrivalsAndDepartures], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalsAndDepartures") + @ExcludeMissing + fun _arrivalsAndDepartures(): JsonField> = + arrivalsAndDepartures + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .arrivalsAndDepartures() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var arrivalsAndDepartures: JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + arrivalsAndDepartures = entry.arrivalsAndDepartures.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun arrivalsAndDepartures(arrivalsAndDepartures: List) = + arrivalsAndDepartures(JsonField.of(arrivalsAndDepartures)) + + /** + * Sets [Builder.arrivalsAndDepartures] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalsAndDepartures] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun arrivalsAndDepartures( + arrivalsAndDepartures: JsonField> + ) = apply { + this.arrivalsAndDepartures = arrivalsAndDepartures.map { it.toMutableList() } + } + + /** + * Adds a single [ArrivalsAndDeparture] to [arrivalsAndDepartures]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArrivalsAndDeparture(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { + arrivalsAndDepartures = + (arrivalsAndDepartures ?: JsonField.of(mutableListOf())).also { + checkKnown("arrivalsAndDepartures", it).add(arrivalsAndDeparture) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .arrivalsAndDepartures() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("arrivalsAndDepartures", arrivalsAndDepartures).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + arrivalsAndDepartures().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (arrivalsAndDepartures.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ArrivalsAndDeparture + private constructor( + private val arrivalEnabled: JsonField, + private val blockTripSequence: JsonField, + private val departureEnabled: JsonField, + private val numberOfStopsAway: JsonField, + private val predictedArrivalTime: JsonField, + private val predictedDepartureTime: JsonField, + private val routeId: JsonField, + private val scheduledArrivalTime: JsonField, + private val scheduledDepartureTime: JsonField, + private val serviceDate: JsonField, + private val stopId: JsonField, + private val stopSequence: JsonField, + private val totalStopsInTrip: JsonField, + private val tripHeadsign: JsonField, + private val tripId: JsonField, + private val vehicleId: JsonField, + private val actualTrack: JsonField, + private val distanceFromStop: JsonField, + private val frequency: JsonField, + private val historicalOccupancy: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyStatus: JsonField, + private val predicted: JsonField, + private val predictedArrivalInterval: JsonField, + private val predictedDepartureInterval: JsonField, + private val predictedOccupancy: JsonField, + private val routeLongName: JsonField, + private val routeShortName: JsonField, + private val scheduledArrivalInterval: JsonField, + private val scheduledDepartureInterval: JsonField, + private val scheduledTrack: JsonField, + private val situationIds: JsonField>, + private val status: JsonField, + private val tripStatus: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalEnabled") + @ExcludeMissing + arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + numberOfStopsAway: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + predictedArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + predictedDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + scheduledArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + scheduledDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopSequence") + @ExcludeMissing + stopSequence: JsonField = JsonMissing.of(), + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + totalStopsInTrip: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("actualTrack") + @ExcludeMissing + actualTrack: JsonField = JsonMissing.of(), + @JsonProperty("distanceFromStop") + @ExcludeMissing + distanceFromStop: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + predictedArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + predictedDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedOccupancy") + @ExcludeMissing + predictedOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("routeLongName") + @ExcludeMissing + routeLongName: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + scheduledArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + scheduledDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledTrack") + @ExcludeMissing + scheduledTrack: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + tripStatus: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + blockTripSequence, + departureEnabled, + numberOfStopsAway, + predictedArrivalTime, + predictedDepartureTime, + routeId, + scheduledArrivalTime, + scheduledDepartureTime, + serviceDate, + stopId, + stopSequence, + totalStopsInTrip, + tripHeadsign, + tripId, + vehicleId, + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + situationIds, + status, + tripStatus, + mutableMapOf(), + ) + + /** + * Indicates if riders can arrive on this transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") + + /** + * Index of this arrival’s trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * Indicates if riders can depart from this transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time + * available). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predictedArrivalTime(): Long = + predictedArrivalTime.getRequired("predictedArrivalTime") + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time + * available). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predictedDepartureTime(): Long = + predictedDepartureTime.getRequired("predictedDepartureTime") + + /** + * The ID of the route for the arriving vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * Scheduled arrival time, in milliseconds since Unix epoch. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduledArrivalTime(): Long = + scheduledArrivalTime.getRequired("scheduledArrivalTime") + + /** + * Scheduled departure time, in milliseconds since Unix epoch. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduledDepartureTime(): Long = + scheduledDepartureTime.getRequired("scheduledDepartureTime") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * The ID of the stop the vehicle is arriving at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopSequence(): Long = stopSequence.getRequired("stopSequence") + + /** + * Total number of stops visited on the trip for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") + + /** + * The ID of the trip for the arriving vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * ID of the transit vehicle serving this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun vehicleId(): String = vehicleId.getRequired("vehicleId") + + /** + * The actual track information of the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun actualTrack(): Optional = actualTrack.getOptional("actualTrack") + + /** + * Distance of the arriving transit vehicle from the stop, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceFromStop(): Optional = + distanceFromStop.getOptional("distanceFromStop") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Historical occupancy information of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun historicalOccupancy(): Optional = + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * Timestamp of the last update time for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastUpdateTime(): Optional = lastUpdateTime.getOptional("lastUpdateTime") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun occupancyStatus(): Optional = + occupancyStatus.getOptional("occupancyStatus") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predicted(): Optional = predicted.getOptional("predicted") + + /** + * Interval for predicted arrival time, if available. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedArrivalInterval(): Optional = + predictedArrivalInterval.getOptional("predictedArrivalInterval") + + /** + * Interval for predicted departure time, if available. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedDepartureInterval(): Optional = + predictedDepartureInterval.getOptional("predictedDepartureInterval") + + /** + * Predicted occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedOccupancy(): Optional = + predictedOccupancy.getOptional("predictedOccupancy") + + /** + * Optional route long name that potentially overrides the route long name in the + * referenced route element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun routeLongName(): Optional = routeLongName.getOptional("routeLongName") + + /** + * Optional route short name that potentially overrides the route short name in the + * referenced route element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun routeShortName(): Optional = + routeShortName.getOptional("routeShortName") + + /** + * Interval for scheduled arrival time. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledArrivalInterval(): Optional = + scheduledArrivalInterval.getOptional("scheduledArrivalInterval") + + /** + * Interval for scheduled departure time. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDepartureInterval(): Optional = + scheduledDepartureInterval.getOptional("scheduledDepartureInterval") + + /** + * Scheduled track information of the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledTrack(): Optional = + scheduledTrack.getOptional("scheduledTrack") + + /** + * References to situation elements (if any) applicable to this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * Current status of the arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Trip-specific status for the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tripStatus(): Optional = tripStatus.getOptional("tripStatus") + + /** + * Returns the raw JSON value of [arrivalEnabled]. + * + * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [departureEnabled]. + * + * Unlike [departureEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("departureEnabled") + @ExcludeMissing + fun _departureEnabled(): JsonField = departureEnabled + + /** + * Returns the raw JSON value of [numberOfStopsAway]. + * + * Unlike [numberOfStopsAway], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + fun _numberOfStopsAway(): JsonField = numberOfStopsAway + + /** + * Returns the raw JSON value of [predictedArrivalTime]. + * + * Unlike [predictedArrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + fun _predictedArrivalTime(): JsonField = predictedArrivalTime + + /** + * Returns the raw JSON value of [predictedDepartureTime]. + * + * Unlike [predictedDepartureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + fun _predictedDepartureTime(): JsonField = predictedDepartureTime + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [scheduledArrivalTime]. + * + * Unlike [scheduledArrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + fun _scheduledArrivalTime(): JsonField = scheduledArrivalTime + + /** + * Returns the raw JSON value of [scheduledDepartureTime]. + * + * Unlike [scheduledDepartureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + fun _scheduledDepartureTime(): JsonField = scheduledDepartureTime + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId + + /** + * Returns the raw JSON value of [stopSequence]. + * + * Unlike [stopSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopSequence") + @ExcludeMissing + fun _stopSequence(): JsonField = stopSequence + + /** + * Returns the raw JSON value of [totalStopsInTrip]. + * + * Unlike [totalStopsInTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + fun _totalStopsInTrip(): JsonField = totalStopsInTrip + + /** + * Returns the raw JSON value of [tripHeadsign]. + * + * Unlike [tripHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + /** + * Returns the raw JSON value of [actualTrack]. + * + * Unlike [actualTrack], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("actualTrack") + @ExcludeMissing + fun _actualTrack(): JsonField = actualTrack + + /** + * Returns the raw JSON value of [distanceFromStop]. + * + * Unlike [distanceFromStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceFromStop") + @ExcludeMissing + fun _distanceFromStop(): JsonField = distanceFromStop + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [historicalOccupancy]. + * + * Unlike [historicalOccupancy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [predictedArrivalInterval]. + * + * Unlike [predictedArrivalInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + fun _predictedArrivalInterval(): JsonField = predictedArrivalInterval + + /** + * Returns the raw JSON value of [predictedDepartureInterval]. + * + * Unlike [predictedDepartureInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + fun _predictedDepartureInterval(): JsonField = predictedDepartureInterval + + /** + * Returns the raw JSON value of [predictedOccupancy]. + * + * Unlike [predictedOccupancy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedOccupancy") + @ExcludeMissing + fun _predictedOccupancy(): JsonField = predictedOccupancy + + /** + * Returns the raw JSON value of [routeLongName]. + * + * Unlike [routeLongName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeLongName") + @ExcludeMissing + fun _routeLongName(): JsonField = routeLongName + + /** + * Returns the raw JSON value of [routeShortName]. + * + * Unlike [routeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName + + /** + * Returns the raw JSON value of [scheduledArrivalInterval]. + * + * Unlike [scheduledArrivalInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + fun _scheduledArrivalInterval(): JsonField = scheduledArrivalInterval + + /** + * Returns the raw JSON value of [scheduledDepartureInterval]. + * + * Unlike [scheduledDepartureInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + fun _scheduledDepartureInterval(): JsonField = scheduledDepartureInterval + + /** + * Returns the raw JSON value of [scheduledTrack]. + * + * Unlike [scheduledTrack], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledTrack") + @ExcludeMissing + fun _scheduledTrack(): JsonField = scheduledTrack + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [tripStatus]. + * + * Unlike [tripStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalsAndDeparture]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .blockTripSequence() + * .departureEnabled() + * .numberOfStopsAway() + * .predictedArrivalTime() + * .predictedDepartureTime() + * .routeId() + * .scheduledArrivalTime() + * .scheduledDepartureTime() + * .serviceDate() + * .stopId() + * .stopSequence() + * .totalStopsInTrip() + * .tripHeadsign() + * .tripId() + * .vehicleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalsAndDeparture]. */ + class Builder internal constructor() { + + private var arrivalEnabled: JsonField? = null + private var blockTripSequence: JsonField? = null + private var departureEnabled: JsonField? = null + private var numberOfStopsAway: JsonField? = null + private var predictedArrivalTime: JsonField? = null + private var predictedDepartureTime: JsonField? = null + private var routeId: JsonField? = null + private var scheduledArrivalTime: JsonField? = null + private var scheduledDepartureTime: JsonField? = null + private var serviceDate: JsonField? = null + private var stopId: JsonField? = null + private var stopSequence: JsonField? = null + private var totalStopsInTrip: JsonField? = null + private var tripHeadsign: JsonField? = null + private var tripId: JsonField? = null + private var vehicleId: JsonField? = null + private var actualTrack: JsonField = JsonMissing.of() + private var distanceFromStop: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var lastUpdateTime: JsonField = JsonMissing.of() + private var occupancyStatus: JsonField = JsonMissing.of() + private var predicted: JsonField = JsonMissing.of() + private var predictedArrivalInterval: JsonField = JsonMissing.of() + private var predictedDepartureInterval: JsonField = JsonMissing.of() + private var predictedOccupancy: JsonField = JsonMissing.of() + private var routeLongName: JsonField = JsonMissing.of() + private var routeShortName: JsonField = JsonMissing.of() + private var scheduledArrivalInterval: JsonField = JsonMissing.of() + private var scheduledDepartureInterval: JsonField = JsonMissing.of() + private var scheduledTrack: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var tripStatus: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { + arrivalEnabled = arrivalsAndDeparture.arrivalEnabled + blockTripSequence = arrivalsAndDeparture.blockTripSequence + departureEnabled = arrivalsAndDeparture.departureEnabled + numberOfStopsAway = arrivalsAndDeparture.numberOfStopsAway + predictedArrivalTime = arrivalsAndDeparture.predictedArrivalTime + predictedDepartureTime = arrivalsAndDeparture.predictedDepartureTime + routeId = arrivalsAndDeparture.routeId + scheduledArrivalTime = arrivalsAndDeparture.scheduledArrivalTime + scheduledDepartureTime = arrivalsAndDeparture.scheduledDepartureTime + serviceDate = arrivalsAndDeparture.serviceDate + stopId = arrivalsAndDeparture.stopId + stopSequence = arrivalsAndDeparture.stopSequence + totalStopsInTrip = arrivalsAndDeparture.totalStopsInTrip + tripHeadsign = arrivalsAndDeparture.tripHeadsign + tripId = arrivalsAndDeparture.tripId + vehicleId = arrivalsAndDeparture.vehicleId + actualTrack = arrivalsAndDeparture.actualTrack + distanceFromStop = arrivalsAndDeparture.distanceFromStop + frequency = arrivalsAndDeparture.frequency + historicalOccupancy = arrivalsAndDeparture.historicalOccupancy + lastUpdateTime = arrivalsAndDeparture.lastUpdateTime + occupancyStatus = arrivalsAndDeparture.occupancyStatus + predicted = arrivalsAndDeparture.predicted + predictedArrivalInterval = arrivalsAndDeparture.predictedArrivalInterval + predictedDepartureInterval = arrivalsAndDeparture.predictedDepartureInterval + predictedOccupancy = arrivalsAndDeparture.predictedOccupancy + routeLongName = arrivalsAndDeparture.routeLongName + routeShortName = arrivalsAndDeparture.routeShortName + scheduledArrivalInterval = arrivalsAndDeparture.scheduledArrivalInterval + scheduledDepartureInterval = arrivalsAndDeparture.scheduledDepartureInterval + scheduledTrack = arrivalsAndDeparture.scheduledTrack + situationIds = arrivalsAndDeparture.situationIds.map { it.toMutableList() } + status = arrivalsAndDeparture.status + tripStatus = arrivalsAndDeparture.tripStatus + additionalProperties = + arrivalsAndDeparture.additionalProperties.toMutableMap() + } + + /** Indicates if riders can arrive on this transit vehicle. */ + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) + + /** + * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arrivalEnabled(arrivalEnabled: JsonField) = apply { + this.arrivalEnabled = arrivalEnabled + } + + /** + * Index of this arrival’s trip into the sequence of trips for the active block. + */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** Indicates if riders can depart from this transit vehicle. */ + fun departureEnabled(departureEnabled: Boolean) = + departureEnabled(JsonField.of(departureEnabled)) + + /** + * Sets [Builder.departureEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.departureEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun departureEnabled(departureEnabled: JsonField) = apply { + this.departureEnabled = departureEnabled + } + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + */ + fun numberOfStopsAway(numberOfStopsAway: Long) = + numberOfStopsAway(JsonField.of(numberOfStopsAway)) + + /** + * Sets [Builder.numberOfStopsAway] to an arbitrary JSON value. + * + * You should usually call [Builder.numberOfStopsAway] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { + this.numberOfStopsAway = numberOfStopsAway + } + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no + * real-time available). + */ + fun predictedArrivalTime(predictedArrivalTime: Long) = + predictedArrivalTime(JsonField.of(predictedArrivalTime)) + + /** + * Sets [Builder.predictedArrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedArrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { + this.predictedArrivalTime = predictedArrivalTime + } + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no + * real-time available). + */ + fun predictedDepartureTime(predictedDepartureTime: Long) = + predictedDepartureTime(JsonField.of(predictedDepartureTime)) + + /** + * Sets [Builder.predictedDepartureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedDepartureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { + this.predictedDepartureTime = predictedDepartureTime + } + + /** The ID of the route for the arriving vehicle. */ + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(scheduledArrivalTime: Long) = + scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) + + /** + * Sets [Builder.scheduledArrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledArrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { + this.scheduledArrivalTime = scheduledArrivalTime + } + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + fun scheduledDepartureTime(scheduledDepartureTime: Long) = + scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) + + /** + * Sets [Builder.scheduledDepartureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDepartureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { + this.scheduledDepartureTime = scheduledDepartureTime + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** The ID of the stop the vehicle is arriving at. */ + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + */ + fun stopSequence(stopSequence: Long) = stopSequence(JsonField.of(stopSequence)) + + /** + * Sets [Builder.stopSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.stopSequence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun stopSequence(stopSequence: JsonField) = apply { + this.stopSequence = stopSequence + } + + /** Total number of stops visited on the trip for this arrival. */ + fun totalStopsInTrip(totalStopsInTrip: Long) = + totalStopsInTrip(JsonField.of(totalStopsInTrip)) + + /** + * Sets [Builder.totalStopsInTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalStopsInTrip] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { + this.totalStopsInTrip = totalStopsInTrip + } + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + */ + fun tripHeadsign(tripHeadsign: String) = + tripHeadsign(JsonField.of(tripHeadsign)) + + /** + * Sets [Builder.tripHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.tripHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripHeadsign(tripHeadsign: JsonField) = apply { + this.tripHeadsign = tripHeadsign + } + + /** The ID of the trip for the arriving vehicle. */ + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + /** ID of the transit vehicle serving this trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + /** The actual track information of the arriving transit vehicle. */ + fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) + + /** + * Sets [Builder.actualTrack] to an arbitrary JSON value. + * + * You should usually call [Builder.actualTrack] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun actualTrack(actualTrack: JsonField) = apply { + this.actualTrack = actualTrack + } + + /** Distance of the arriving transit vehicle from the stop, in meters. */ + fun distanceFromStop(distanceFromStop: Double) = + distanceFromStop(JsonField.of(distanceFromStop)) + + /** + * Sets [Builder.distanceFromStop] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceFromStop] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceFromStop(distanceFromStop: JsonField) = apply { + this.distanceFromStop = distanceFromStop + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Historical occupancy information of the transit vehicle. */ + fun historicalOccupancy(historicalOccupancy: String) = + historicalOccupancy(JsonField.of(historicalOccupancy)) + + /** + * Sets [Builder.historicalOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.historicalOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun historicalOccupancy(historicalOccupancy: JsonField) = apply { + this.historicalOccupancy = historicalOccupancy + } + + /** Timestamp of the last update time for this arrival. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** Interval for predicted arrival time, if available. */ + fun predictedArrivalInterval(predictedArrivalInterval: String) = + predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) + + /** + * Sets [Builder.predictedArrivalInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedArrivalInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = + apply { + this.predictedArrivalInterval = predictedArrivalInterval + } + + /** Interval for predicted departure time, if available. */ + fun predictedDepartureInterval(predictedDepartureInterval: String) = + predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) + + /** + * Sets [Builder.predictedDepartureInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedDepartureInterval] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = + apply { + this.predictedDepartureInterval = predictedDepartureInterval + } + + /** Predicted occupancy status of the transit vehicle. */ + fun predictedOccupancy(predictedOccupancy: String) = + predictedOccupancy(JsonField.of(predictedOccupancy)) + + /** + * Sets [Builder.predictedOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedOccupancy(predictedOccupancy: JsonField) = apply { + this.predictedOccupancy = predictedOccupancy + } + + /** + * Optional route long name that potentially overrides the route long name in + * the referenced route element. + */ + fun routeLongName(routeLongName: String) = + routeLongName(JsonField.of(routeLongName)) + + /** + * Sets [Builder.routeLongName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeLongName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun routeLongName(routeLongName: JsonField) = apply { + this.routeLongName = routeLongName + } + + /** + * Optional route short name that potentially overrides the route short name in + * the referenced route element. + */ + fun routeShortName(routeShortName: String) = + routeShortName(JsonField.of(routeShortName)) + + /** + * Sets [Builder.routeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun routeShortName(routeShortName: JsonField) = apply { + this.routeShortName = routeShortName + } + + /** Interval for scheduled arrival time. */ + fun scheduledArrivalInterval(scheduledArrivalInterval: String) = + scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) + + /** + * Sets [Builder.scheduledArrivalInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledArrivalInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = + apply { + this.scheduledArrivalInterval = scheduledArrivalInterval + } + + /** Interval for scheduled departure time. */ + fun scheduledDepartureInterval(scheduledDepartureInterval: String) = + scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) + + /** + * Sets [Builder.scheduledDepartureInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDepartureInterval] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = + apply { + this.scheduledDepartureInterval = scheduledDepartureInterval + } + + /** Scheduled track information of the arriving transit vehicle. */ + fun scheduledTrack(scheduledTrack: String) = + scheduledTrack(JsonField.of(scheduledTrack)) + + /** + * Sets [Builder.scheduledTrack] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledTrack] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledTrack(scheduledTrack: JsonField) = apply { + this.scheduledTrack = scheduledTrack + } + + /** References to situation elements (if any) applicable to this arrival. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** Current status of the arrival. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Trip-specific status for the arriving transit vehicle. */ + fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) + + /** + * Sets [Builder.tripStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.tripStatus] with a well-typed [TripStatus] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripStatus(tripStatus: JsonField) = apply { + this.tripStatus = tripStatus + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ArrivalsAndDeparture]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .blockTripSequence() + * .departureEnabled() + * .numberOfStopsAway() + * .predictedArrivalTime() + * .predictedDepartureTime() + * .routeId() + * .scheduledArrivalTime() + * .scheduledDepartureTime() + * .serviceDate() + * .stopId() + * .stopSequence() + * .totalStopsInTrip() + * .tripHeadsign() + * .tripId() + * .vehicleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArrivalsAndDeparture = + ArrivalsAndDeparture( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("departureEnabled", departureEnabled), + checkRequired("numberOfStopsAway", numberOfStopsAway), + checkRequired("predictedArrivalTime", predictedArrivalTime), + checkRequired("predictedDepartureTime", predictedDepartureTime), + checkRequired("routeId", routeId), + checkRequired("scheduledArrivalTime", scheduledArrivalTime), + checkRequired("scheduledDepartureTime", scheduledDepartureTime), + checkRequired("serviceDate", serviceDate), + checkRequired("stopId", stopId), + checkRequired("stopSequence", stopSequence), + checkRequired("totalStopsInTrip", totalStopsInTrip), + checkRequired("tripHeadsign", tripHeadsign), + checkRequired("tripId", tripId), + checkRequired("vehicleId", vehicleId), + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + status, + tripStatus, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ArrivalsAndDeparture = apply { + if (validated) { + return@apply + } + + arrivalEnabled() + blockTripSequence() + departureEnabled() + numberOfStopsAway() + predictedArrivalTime() + predictedDepartureTime() + routeId() + scheduledArrivalTime() + scheduledDepartureTime() + serviceDate() + stopId() + stopSequence() + totalStopsInTrip() + tripHeadsign() + tripId() + vehicleId() + actualTrack() + distanceFromStop() + frequency() + historicalOccupancy() + lastUpdateTime() + occupancyStatus() + predicted() + predictedArrivalInterval() + predictedDepartureInterval() + predictedOccupancy() + routeLongName() + routeShortName() + scheduledArrivalInterval() + scheduledDepartureInterval() + scheduledTrack() + situationIds() + status() + tripStatus().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (departureEnabled.asKnown().isPresent) 1 else 0) + + (if (numberOfStopsAway.asKnown().isPresent) 1 else 0) + + (if (predictedArrivalTime.asKnown().isPresent) 1 else 0) + + (if (predictedDepartureTime.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (scheduledArrivalTime.asKnown().isPresent) 1 else 0) + + (if (scheduledDepartureTime.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (stopSequence.asKnown().isPresent) 1 else 0) + + (if (totalStopsInTrip.asKnown().isPresent) 1 else 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + (if (actualTrack.asKnown().isPresent) 1 else 0) + + (if (distanceFromStop.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (predictedArrivalInterval.asKnown().isPresent) 1 else 0) + + (if (predictedDepartureInterval.asKnown().isPresent) 1 else 0) + + (if (predictedOccupancy.asKnown().isPresent) 1 else 0) + + (if (routeLongName.asKnown().isPresent) 1 else 0) + + (if (routeShortName.asKnown().isPresent) 1 else 0) + + (if (scheduledArrivalInterval.asKnown().isPresent) 1 else 0) + + (if (scheduledDepartureInterval.asKnown().isPresent) 1 else 0) + + (if (scheduledTrack.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (tripStatus.asKnown().getOrNull()?.validity() ?: 0) + + /** Trip-specific status for the arriving transit vehicle. */ + class TripStatus + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun blockTripSequence(): Long = + blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun distanceAlongTrip(): Double = + distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyCapacity(): Long = + occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scheduleDeviation(): Long = + scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownLocation(): Optional = + lastKnownLocation.getOptional("lastKnownLocation") + + /** + * Last known orientation value received in real-time from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownOrientation(): Optional = + lastKnownOrientation.getOptional("lastKnownOrientation") + + /** + * ID of the next stop the transit vehicle is scheduled to arrive at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStop(): Optional = nextStop.getOptional("nextStop") + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStopTimeOffset(): Optional = + nextStopTimeOffset.getOptional("nextStopTimeOffset") + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("orientation") + + /** + * Current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDistanceAlongTrip(): Optional = + scheduledDistanceAlongTrip.getOptional("scheduledDistanceAlongTrip") + + /** + * References to situation elements (if any) applicable to this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * ID of the transit vehicle currently serving the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vehicleId(): Optional = vehicleId.getOptional("vehicleId") + + /** + * Returns the raw JSON value of [activeTripId]. + * + * Unlike [activeTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [closestStop]. + * + * Unlike [closestStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [lastKnownDistanceAlongTrip]. + * + * Unlike [lastKnownDistanceAlongTrip], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = + lastKnownDistanceAlongTrip + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [scheduleDeviation]. + * + * Unlike [scheduleDeviation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduleDeviation") + @ExcludeMissing + fun _scheduleDeviation(): JsonField = scheduleDeviation + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [totalDistanceAlongTrip]. + * + * Unlike [totalDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Returns the raw JSON value of [closestStopTimeOffset]. + * + * Unlike [closestStopTimeOffset], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [lastKnownLocation]. + * + * Unlike [lastKnownLocation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Returns the raw JSON value of [lastKnownOrientation]. + * + * Unlike [lastKnownOrientation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** + * Returns the raw JSON value of [nextStop]. + * + * Unlike [nextStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Returns the raw JSON value of [nextStopTimeOffset]. + * + * Unlike [nextStopTimeOffset], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [scheduledDistanceAlongTrip]. + * + * Unlike [scheduledDistanceAlongTrip], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = + scheduledDistanceAlongTrip + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripStatus]. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripStatus]. */ + class Builder internal constructor() { + + private var activeTripId: JsonField? = null + private var blockTripSequence: JsonField? = null + private var closestStop: JsonField? = null + private var distanceAlongTrip: JsonField? = null + private var lastKnownDistanceAlongTrip: JsonField? = null + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var occupancyCapacity: JsonField? = null + private var occupancyCount: JsonField? = null + private var occupancyStatus: JsonField? = null + private var phase: JsonField? = null + private var predicted: JsonField? = null + private var scheduleDeviation: JsonField? = null + private var serviceDate: JsonField? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null + private var closestStopTimeOffset: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var lastKnownLocation: JsonField = + JsonMissing.of() + private var lastKnownOrientation: JsonField = JsonMissing.of() + private var nextStop: JsonField = JsonMissing.of() + private var nextStopTimeOffset: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var vehicleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tripStatus: TripStatus) = apply { + activeTripId = tripStatus.activeTripId + blockTripSequence = tripStatus.blockTripSequence + closestStop = tripStatus.closestStop + distanceAlongTrip = tripStatus.distanceAlongTrip + lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip + lastLocationUpdateTime = tripStatus.lastLocationUpdateTime + lastUpdateTime = tripStatus.lastUpdateTime + occupancyCapacity = tripStatus.occupancyCapacity + occupancyCount = tripStatus.occupancyCount + occupancyStatus = tripStatus.occupancyStatus + phase = tripStatus.phase + predicted = tripStatus.predicted + scheduleDeviation = tripStatus.scheduleDeviation + serviceDate = tripStatus.serviceDate + status = tripStatus.status + totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip + closestStopTimeOffset = tripStatus.closestStopTimeOffset + frequency = tripStatus.frequency + lastKnownLocation = tripStatus.lastKnownLocation + lastKnownOrientation = tripStatus.lastKnownOrientation + nextStop = tripStatus.nextStop + nextStopTimeOffset = tripStatus.nextStopTimeOffset + orientation = tripStatus.orientation + position = tripStatus.position + scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip + situationIds = tripStatus.situationIds.map { it.toMutableList() } + vehicleId = tripStatus.vehicleId + additionalProperties = tripStatus.additionalProperties.toMutableMap() + } + + /** Trip ID of the trip the vehicle is actively serving. */ + fun activeTripId(activeTripId: String) = + activeTripId(JsonField.of(activeTripId)) + + /** + * Sets [Builder.activeTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.activeTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun activeTripId(activeTripId: JsonField) = apply { + this.activeTripId = activeTripId + } + + /** + * Index of the active trip into the sequence of trips for the active block. + */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** + * ID of the closest stop to the current location of the transit vehicle. + */ + fun closestStop(closestStop: String) = + closestStop(JsonField.of(closestStop)) + + /** + * Sets [Builder.closestStop] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStop(closestStop: JsonField) = apply { + this.closestStop = closestStop + } + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + */ + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = + lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) + + /** + * Sets [Builder.lastKnownDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun lastKnownDistanceAlongTrip( + lastKnownDistanceAlongTrip: JsonField + ) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a + * well-typed [Long] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = + apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + /** + * Timestamp of the last known real-time update from the transit vehicle. + */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Capacity of the transit vehicle in terms of occupancy. */ + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + /** Current count of occupants in the transit vehicle. */ + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Current journey phase of the trip. */ + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + */ + fun scheduleDeviation(scheduleDeviation: Long) = + scheduleDeviation(JsonField.of(scheduleDeviation)) + + /** + * Sets [Builder.scheduleDeviation] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDeviation] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun scheduleDeviation(scheduleDeviation: JsonField) = apply { + this.scheduleDeviation = scheduleDeviation + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of + * the service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** Current status modifiers for the trip. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total length of the trip, in meters. */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = + totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) + + /** + * Sets [Builder.totalDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = + apply { + this.totalDistanceAlongTrip = totalDistanceAlongTrip + } + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(closestStopTimeOffset: Long) = + closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) + + /** + * Sets [Builder.closestStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { + this.closestStopTimeOffset = closestStopTimeOffset + } + + /** + * Information about frequency-based scheduling, if applicable to the trip. + */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownLocation] with a well-typed + * [LastKnownLocation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun lastKnownLocation(lastKnownLocation: JsonField) = + apply { + this.lastKnownLocation = lastKnownLocation + } + + /** + * Last known orientation value received in real-time from the transit + * vehicle. + */ + fun lastKnownOrientation(lastKnownOrientation: Double) = + lastKnownOrientation(JsonField.of(lastKnownOrientation)) + + /** + * Sets [Builder.lastKnownOrientation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownOrientation] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { + this.lastKnownOrientation = lastKnownOrientation + } + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) + + /** + * Sets [Builder.nextStop] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nextStop(nextStop: JsonField) = apply { + this.nextStop = nextStop + } + + /** + * Time offset from the next stop to the current position of the transit + * vehicle (in seconds). + */ + fun nextStopTimeOffset(nextStopTimeOffset: Long) = + nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) + + /** + * Sets [Builder.nextStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { + this.nextStopTimeOffset = nextStopTimeOffset + } + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + */ + fun orientation(orientation: Double) = + orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun position(position: JsonField) = apply { + this.position = position + } + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = + scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) + + /** + * Sets [Builder.scheduledDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scheduledDistanceAlongTrip( + scheduledDistanceAlongTrip: JsonField + ) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripStatus = + TripStatus( + checkRequired("activeTripId", activeTripId), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("closestStop", closestStop), + checkRequired("distanceAlongTrip", distanceAlongTrip), + checkRequired( + "lastKnownDistanceAlongTrip", + lastKnownDistanceAlongTrip, + ), + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("occupancyCapacity", occupancyCapacity), + checkRequired("occupancyCount", occupancyCount), + checkRequired("occupancyStatus", occupancyStatus), + checkRequired("phase", phase), + checkRequired("predicted", predicted), + checkRequired("scheduleDeviation", scheduleDeviation), + checkRequired("serviceDate", serviceDate), + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + vehicleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripStatus = apply { + if (validated) { + return@apply + } + + activeTripId() + blockTripSequence() + closestStop() + distanceAlongTrip() + lastKnownDistanceAlongTrip() + lastLocationUpdateTime() + lastUpdateTime() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + predicted() + scheduleDeviation() + serviceDate() + status() + totalDistanceAlongTrip() + closestStopTimeOffset() + frequency() + lastKnownLocation().ifPresent { it.validate() } + lastKnownOrientation() + nextStop() + nextStopTimeOffset() + orientation() + position().ifPresent { it.validate() } + scheduledDistanceAlongTrip() + situationIds() + vehicleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (activeTripId.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (closestStop.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastKnownDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (scheduleDeviation.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (totalDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (closestStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (lastKnownLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastKnownOrientation.asKnown().isPresent) 1 else 0) + + (if (nextStop.asKnown().isPresent) 1 else 0) + + (if (nextStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + + (if (scheduledDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + /** Last known location of the transit vehicle. */ + class LastKnownLocation + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Position]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && distanceAlongTrip == other.distanceAlongTrip && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && serviceDate == other.serviceDate && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && closestStopTimeOffset == other.closestStopTimeOffset && frequency == other.frequency && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && orientation == other.orientation && position == other.position && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && situationIds == other.situationIds && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, distanceAlongTrip, lastKnownDistanceAlongTrip, lastLocationUpdateTime, lastUpdateTime, occupancyCapacity, occupancyCount, occupancyStatus, phase, predicted, scheduleDeviation, serviceDate, status, totalDistanceAlongTrip, closestStopTimeOffset, frequency, lastKnownLocation, lastKnownOrientation, nextStop, nextStopTimeOffset, orientation, position, scheduledDistanceAlongTrip, situationIds, vehicleId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ArrivalsAndDeparture && arrivalEnabled == other.arrivalEnabled && blockTripSequence == other.blockTripSequence && departureEnabled == other.departureEnabled && numberOfStopsAway == other.numberOfStopsAway && predictedArrivalTime == other.predictedArrivalTime && predictedDepartureTime == other.predictedDepartureTime && routeId == other.routeId && scheduledArrivalTime == other.scheduledArrivalTime && scheduledDepartureTime == other.scheduledDepartureTime && serviceDate == other.serviceDate && stopId == other.stopId && stopSequence == other.stopSequence && totalStopsInTrip == other.totalStopsInTrip && tripHeadsign == other.tripHeadsign && tripId == other.tripId && vehicleId == other.vehicleId && actualTrack == other.actualTrack && distanceFromStop == other.distanceFromStop && frequency == other.frequency && historicalOccupancy == other.historicalOccupancy && lastUpdateTime == other.lastUpdateTime && occupancyStatus == other.occupancyStatus && predicted == other.predicted && predictedArrivalInterval == other.predictedArrivalInterval && predictedDepartureInterval == other.predictedDepartureInterval && predictedOccupancy == other.predictedOccupancy && routeLongName == other.routeLongName && routeShortName == other.routeShortName && scheduledArrivalInterval == other.scheduledArrivalInterval && scheduledDepartureInterval == other.scheduledDepartureInterval && scheduledTrack == other.scheduledTrack && situationIds == other.situationIds && status == other.status && tripStatus == other.tripStatus && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, blockTripSequence, departureEnabled, numberOfStopsAway, predictedArrivalTime, predictedDepartureTime, routeId, scheduledArrivalTime, scheduledDepartureTime, serviceDate, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, vehicleId, actualTrack, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, occupancyStatus, predicted, predictedArrivalInterval, predictedDepartureInterval, predictedOccupancy, routeLongName, routeShortName, scheduledArrivalInterval, scheduledDepartureInterval, scheduledTrack, situationIds, status, tripStatus, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ArrivalsAndDeparture{arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, numberOfStopsAway=$numberOfStopsAway, predictedArrivalTime=$predictedArrivalTime, predictedDepartureTime=$predictedDepartureTime, routeId=$routeId, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureTime=$scheduledDepartureTime, serviceDate=$serviceDate, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, vehicleId=$vehicleId, actualTrack=$actualTrack, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedDepartureInterval=$predictedDepartureInterval, predictedOccupancy=$predictedOccupancy, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledTrack=$scheduledTrack, situationIds=$situationIds, status=$status, tripStatus=$tripStatus, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && arrivalsAndDepartures == other.arrivalsAndDepartures && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalsAndDepartures, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{arrivalsAndDepartures=$arrivalsAndDepartures, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ArrivalAndDepartureListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ArrivalAndDepartureListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt new file mode 100644 index 0000000..2d86a66 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt @@ -0,0 +1,279 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is ArrivalAndDepartureRetrieveParams && stopId == other.stopId && serviceDate == other.serviceDate && tripId == other.tripId && stopSequence == other.stopSequence && time == other.time && vehicleId == other.vehicleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, serviceDate, tripId, stopSequence, time, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ArrivalAndDepartureRetrieveParams{stopId=$stopId, serviceDate=$serviceDate, tripId=$tripId, stopSequence=$stopSequence, time=$time, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt new file mode 100644 index 0000000..2a83e0a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt @@ -0,0 +1,3922 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class ArrivalAndDepartureRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalAndDepartureRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalAndDepartureRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + arrivalAndDepartureRetrieveResponse: ArrivalAndDepartureRetrieveResponse + ) = apply { + code = arrivalAndDepartureRetrieveResponse.code + currentTime = arrivalAndDepartureRetrieveResponse.currentTime + text = arrivalAndDepartureRetrieveResponse.text + version = arrivalAndDepartureRetrieveResponse.version + data = arrivalAndDepartureRetrieveResponse.data + additionalProperties = + arrivalAndDepartureRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ArrivalAndDepartureRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArrivalAndDepartureRetrieveResponse = + ArrivalAndDepartureRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ArrivalAndDepartureRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val arrivalEnabled: JsonField, + private val blockTripSequence: JsonField, + private val departureEnabled: JsonField, + private val numberOfStopsAway: JsonField, + private val predictedArrivalTime: JsonField, + private val predictedDepartureTime: JsonField, + private val routeId: JsonField, + private val scheduledArrivalTime: JsonField, + private val scheduledDepartureTime: JsonField, + private val serviceDate: JsonField, + private val stopId: JsonField, + private val stopSequence: JsonField, + private val totalStopsInTrip: JsonField, + private val tripHeadsign: JsonField, + private val tripId: JsonField, + private val vehicleId: JsonField, + private val actualTrack: JsonField, + private val distanceFromStop: JsonField, + private val frequency: JsonField, + private val historicalOccupancy: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyStatus: JsonField, + private val predicted: JsonField, + private val predictedArrivalInterval: JsonField, + private val predictedDepartureInterval: JsonField, + private val predictedOccupancy: JsonField, + private val routeLongName: JsonField, + private val routeShortName: JsonField, + private val scheduledArrivalInterval: JsonField, + private val scheduledDepartureInterval: JsonField, + private val scheduledTrack: JsonField, + private val situationIds: JsonField>, + private val status: JsonField, + private val tripStatus: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalEnabled") + @ExcludeMissing + arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + numberOfStopsAway: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + predictedArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + predictedDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + scheduledArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + scheduledDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopSequence") + @ExcludeMissing + stopSequence: JsonField = JsonMissing.of(), + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + totalStopsInTrip: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("actualTrack") + @ExcludeMissing + actualTrack: JsonField = JsonMissing.of(), + @JsonProperty("distanceFromStop") + @ExcludeMissing + distanceFromStop: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + predictedArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + predictedDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedOccupancy") + @ExcludeMissing + predictedOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("routeLongName") + @ExcludeMissing + routeLongName: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + scheduledArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + scheduledDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledTrack") + @ExcludeMissing + scheduledTrack: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + tripStatus: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + blockTripSequence, + departureEnabled, + numberOfStopsAway, + predictedArrivalTime, + predictedDepartureTime, + routeId, + scheduledArrivalTime, + scheduledDepartureTime, + serviceDate, + stopId, + stopSequence, + totalStopsInTrip, + tripHeadsign, + tripId, + vehicleId, + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + situationIds, + status, + tripStatus, + mutableMapOf(), + ) + + /** + * Indicates if riders can arrive on this transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") + + /** + * Index of this arrival’s trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * Indicates if riders can depart from this transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") + + /** + * Number of stops between the arriving transit vehicle and the current stop (excluding + * the current stop). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time + * available). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun predictedArrivalTime(): Long = + predictedArrivalTime.getRequired("predictedArrivalTime") + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time + * available). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun predictedDepartureTime(): Long = + predictedDepartureTime.getRequired("predictedDepartureTime") + + /** + * The ID of the route for the arriving vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * Scheduled arrival time, in milliseconds since Unix epoch. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scheduledArrivalTime(): Long = + scheduledArrivalTime.getRequired("scheduledArrivalTime") + + /** + * Scheduled departure time, in milliseconds since Unix epoch. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scheduledDepartureTime(): Long = + scheduledDepartureTime.getRequired("scheduledDepartureTime") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the service + * date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * The ID of the stop the vehicle is arriving at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * Index of the stop into the sequence of stops that make up the trip for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun stopSequence(): Long = stopSequence.getRequired("stopSequence") + + /** + * Total number of stops visited on the trip for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") + + /** + * Optional trip headsign that potentially overrides the trip headsign in the referenced + * trip element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") + + /** + * The ID of the trip for the arriving vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * ID of the transit vehicle serving this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun vehicleId(): String = vehicleId.getRequired("vehicleId") + + /** + * The actual track information of the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun actualTrack(): Optional = actualTrack.getOptional("actualTrack") + + /** + * Distance of the arriving transit vehicle from the stop, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun distanceFromStop(): Optional = + distanceFromStop.getOptional("distanceFromStop") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Historical occupancy information of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun historicalOccupancy(): Optional = + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * Timestamp of the last update time for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lastUpdateTime(): Optional = lastUpdateTime.getOptional("lastUpdateTime") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun occupancyStatus(): Optional = occupancyStatus.getOptional("occupancyStatus") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun predicted(): Optional = predicted.getOptional("predicted") + + /** + * Interval for predicted arrival time, if available. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun predictedArrivalInterval(): Optional = + predictedArrivalInterval.getOptional("predictedArrivalInterval") + + /** + * Interval for predicted departure time, if available. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun predictedDepartureInterval(): Optional = + predictedDepartureInterval.getOptional("predictedDepartureInterval") + + /** + * Predicted occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun predictedOccupancy(): Optional = + predictedOccupancy.getOptional("predictedOccupancy") + + /** + * Optional route long name that potentially overrides the route long name in the + * referenced route element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun routeLongName(): Optional = routeLongName.getOptional("routeLongName") + + /** + * Optional route short name that potentially overrides the route short name in the + * referenced route element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun routeShortName(): Optional = routeShortName.getOptional("routeShortName") + + /** + * Interval for scheduled arrival time. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun scheduledArrivalInterval(): Optional = + scheduledArrivalInterval.getOptional("scheduledArrivalInterval") + + /** + * Interval for scheduled departure time. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun scheduledDepartureInterval(): Optional = + scheduledDepartureInterval.getOptional("scheduledDepartureInterval") + + /** + * Scheduled track information of the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun scheduledTrack(): Optional = scheduledTrack.getOptional("scheduledTrack") + + /** + * References to situation elements (if any) applicable to this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = situationIds.getOptional("situationIds") + + /** + * Current status of the arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Trip-specific status for the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tripStatus(): Optional = tripStatus.getOptional("tripStatus") + + /** + * Returns the raw JSON value of [arrivalEnabled]. + * + * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [departureEnabled]. + * + * Unlike [departureEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("departureEnabled") + @ExcludeMissing + fun _departureEnabled(): JsonField = departureEnabled + + /** + * Returns the raw JSON value of [numberOfStopsAway]. + * + * Unlike [numberOfStopsAway], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + fun _numberOfStopsAway(): JsonField = numberOfStopsAway + + /** + * Returns the raw JSON value of [predictedArrivalTime]. + * + * Unlike [predictedArrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + fun _predictedArrivalTime(): JsonField = predictedArrivalTime + + /** + * Returns the raw JSON value of [predictedDepartureTime]. + * + * Unlike [predictedDepartureTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + fun _predictedDepartureTime(): JsonField = predictedDepartureTime + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [scheduledArrivalTime]. + * + * Unlike [scheduledArrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + fun _scheduledArrivalTime(): JsonField = scheduledArrivalTime + + /** + * Returns the raw JSON value of [scheduledDepartureTime]. + * + * Unlike [scheduledDepartureTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + fun _scheduledDepartureTime(): JsonField = scheduledDepartureTime + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId + + /** + * Returns the raw JSON value of [stopSequence]. + * + * Unlike [stopSequence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopSequence") + @ExcludeMissing + fun _stopSequence(): JsonField = stopSequence + + /** + * Returns the raw JSON value of [totalStopsInTrip]. + * + * Unlike [totalStopsInTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + fun _totalStopsInTrip(): JsonField = totalStopsInTrip + + /** + * Returns the raw JSON value of [tripHeadsign]. + * + * Unlike [tripHeadsign], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + /** + * Returns the raw JSON value of [actualTrack]. + * + * Unlike [actualTrack], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("actualTrack") + @ExcludeMissing + fun _actualTrack(): JsonField = actualTrack + + /** + * Returns the raw JSON value of [distanceFromStop]. + * + * Unlike [distanceFromStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceFromStop") + @ExcludeMissing + fun _distanceFromStop(): JsonField = distanceFromStop + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [historicalOccupancy]. + * + * Unlike [historicalOccupancy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [predictedArrivalInterval]. + * + * Unlike [predictedArrivalInterval], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + fun _predictedArrivalInterval(): JsonField = predictedArrivalInterval + + /** + * Returns the raw JSON value of [predictedDepartureInterval]. + * + * Unlike [predictedDepartureInterval], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + fun _predictedDepartureInterval(): JsonField = predictedDepartureInterval + + /** + * Returns the raw JSON value of [predictedOccupancy]. + * + * Unlike [predictedOccupancy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedOccupancy") + @ExcludeMissing + fun _predictedOccupancy(): JsonField = predictedOccupancy + + /** + * Returns the raw JSON value of [routeLongName]. + * + * Unlike [routeLongName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeLongName") + @ExcludeMissing + fun _routeLongName(): JsonField = routeLongName + + /** + * Returns the raw JSON value of [routeShortName]. + * + * Unlike [routeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName + + /** + * Returns the raw JSON value of [scheduledArrivalInterval]. + * + * Unlike [scheduledArrivalInterval], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + fun _scheduledArrivalInterval(): JsonField = scheduledArrivalInterval + + /** + * Returns the raw JSON value of [scheduledDepartureInterval]. + * + * Unlike [scheduledDepartureInterval], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + fun _scheduledDepartureInterval(): JsonField = scheduledDepartureInterval + + /** + * Returns the raw JSON value of [scheduledTrack]. + * + * Unlike [scheduledTrack], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledTrack") + @ExcludeMissing + fun _scheduledTrack(): JsonField = scheduledTrack + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [tripStatus]. + * + * Unlike [tripStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .blockTripSequence() + * .departureEnabled() + * .numberOfStopsAway() + * .predictedArrivalTime() + * .predictedDepartureTime() + * .routeId() + * .scheduledArrivalTime() + * .scheduledDepartureTime() + * .serviceDate() + * .stopId() + * .stopSequence() + * .totalStopsInTrip() + * .tripHeadsign() + * .tripId() + * .vehicleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var arrivalEnabled: JsonField? = null + private var blockTripSequence: JsonField? = null + private var departureEnabled: JsonField? = null + private var numberOfStopsAway: JsonField? = null + private var predictedArrivalTime: JsonField? = null + private var predictedDepartureTime: JsonField? = null + private var routeId: JsonField? = null + private var scheduledArrivalTime: JsonField? = null + private var scheduledDepartureTime: JsonField? = null + private var serviceDate: JsonField? = null + private var stopId: JsonField? = null + private var stopSequence: JsonField? = null + private var totalStopsInTrip: JsonField? = null + private var tripHeadsign: JsonField? = null + private var tripId: JsonField? = null + private var vehicleId: JsonField? = null + private var actualTrack: JsonField = JsonMissing.of() + private var distanceFromStop: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var lastUpdateTime: JsonField = JsonMissing.of() + private var occupancyStatus: JsonField = JsonMissing.of() + private var predicted: JsonField = JsonMissing.of() + private var predictedArrivalInterval: JsonField = JsonMissing.of() + private var predictedDepartureInterval: JsonField = JsonMissing.of() + private var predictedOccupancy: JsonField = JsonMissing.of() + private var routeLongName: JsonField = JsonMissing.of() + private var routeShortName: JsonField = JsonMissing.of() + private var scheduledArrivalInterval: JsonField = JsonMissing.of() + private var scheduledDepartureInterval: JsonField = JsonMissing.of() + private var scheduledTrack: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var tripStatus: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + arrivalEnabled = entry.arrivalEnabled + blockTripSequence = entry.blockTripSequence + departureEnabled = entry.departureEnabled + numberOfStopsAway = entry.numberOfStopsAway + predictedArrivalTime = entry.predictedArrivalTime + predictedDepartureTime = entry.predictedDepartureTime + routeId = entry.routeId + scheduledArrivalTime = entry.scheduledArrivalTime + scheduledDepartureTime = entry.scheduledDepartureTime + serviceDate = entry.serviceDate + stopId = entry.stopId + stopSequence = entry.stopSequence + totalStopsInTrip = entry.totalStopsInTrip + tripHeadsign = entry.tripHeadsign + tripId = entry.tripId + vehicleId = entry.vehicleId + actualTrack = entry.actualTrack + distanceFromStop = entry.distanceFromStop + frequency = entry.frequency + historicalOccupancy = entry.historicalOccupancy + lastUpdateTime = entry.lastUpdateTime + occupancyStatus = entry.occupancyStatus + predicted = entry.predicted + predictedArrivalInterval = entry.predictedArrivalInterval + predictedDepartureInterval = entry.predictedDepartureInterval + predictedOccupancy = entry.predictedOccupancy + routeLongName = entry.routeLongName + routeShortName = entry.routeShortName + scheduledArrivalInterval = entry.scheduledArrivalInterval + scheduledDepartureInterval = entry.scheduledDepartureInterval + scheduledTrack = entry.scheduledTrack + situationIds = entry.situationIds.map { it.toMutableList() } + status = entry.status + tripStatus = entry.tripStatus + additionalProperties = entry.additionalProperties.toMutableMap() + } + + /** Indicates if riders can arrive on this transit vehicle. */ + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) + + /** + * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun arrivalEnabled(arrivalEnabled: JsonField) = apply { + this.arrivalEnabled = arrivalEnabled + } + + /** Index of this arrival’s trip into the sequence of trips for the active block. */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** Indicates if riders can depart from this transit vehicle. */ + fun departureEnabled(departureEnabled: Boolean) = + departureEnabled(JsonField.of(departureEnabled)) + + /** + * Sets [Builder.departureEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.departureEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun departureEnabled(departureEnabled: JsonField) = apply { + this.departureEnabled = departureEnabled + } + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + */ + fun numberOfStopsAway(numberOfStopsAway: Long) = + numberOfStopsAway(JsonField.of(numberOfStopsAway)) + + /** + * Sets [Builder.numberOfStopsAway] to an arbitrary JSON value. + * + * You should usually call [Builder.numberOfStopsAway] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { + this.numberOfStopsAway = numberOfStopsAway + } + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time + * available). + */ + fun predictedArrivalTime(predictedArrivalTime: Long) = + predictedArrivalTime(JsonField.of(predictedArrivalTime)) + + /** + * Sets [Builder.predictedArrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedArrivalTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { + this.predictedArrivalTime = predictedArrivalTime + } + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time + * available). + */ + fun predictedDepartureTime(predictedDepartureTime: Long) = + predictedDepartureTime(JsonField.of(predictedDepartureTime)) + + /** + * Sets [Builder.predictedDepartureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedDepartureTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { + this.predictedDepartureTime = predictedDepartureTime + } + + /** The ID of the route for the arriving vehicle. */ + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(scheduledArrivalTime: Long) = + scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) + + /** + * Sets [Builder.scheduledArrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledArrivalTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { + this.scheduledArrivalTime = scheduledArrivalTime + } + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + fun scheduledDepartureTime(scheduledDepartureTime: Long) = + scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) + + /** + * Sets [Builder.scheduledDepartureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDepartureTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { + this.scheduledDepartureTime = scheduledDepartureTime + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** The ID of the stop the vehicle is arriving at. */ + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + */ + fun stopSequence(stopSequence: Long) = stopSequence(JsonField.of(stopSequence)) + + /** + * Sets [Builder.stopSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.stopSequence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun stopSequence(stopSequence: JsonField) = apply { + this.stopSequence = stopSequence + } + + /** Total number of stops visited on the trip for this arrival. */ + fun totalStopsInTrip(totalStopsInTrip: Long) = + totalStopsInTrip(JsonField.of(totalStopsInTrip)) + + /** + * Sets [Builder.totalStopsInTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalStopsInTrip] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { + this.totalStopsInTrip = totalStopsInTrip + } + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + */ + fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) + + /** + * Sets [Builder.tripHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.tripHeadsign] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripHeadsign(tripHeadsign: JsonField) = apply { + this.tripHeadsign = tripHeadsign + } + + /** The ID of the trip for the arriving vehicle. */ + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + /** ID of the transit vehicle serving this trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } + + /** The actual track information of the arriving transit vehicle. */ + fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) + + /** + * Sets [Builder.actualTrack] to an arbitrary JSON value. + * + * You should usually call [Builder.actualTrack] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun actualTrack(actualTrack: JsonField) = apply { + this.actualTrack = actualTrack + } + + /** Distance of the arriving transit vehicle from the stop, in meters. */ + fun distanceFromStop(distanceFromStop: Double) = + distanceFromStop(JsonField.of(distanceFromStop)) + + /** + * Sets [Builder.distanceFromStop] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceFromStop] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun distanceFromStop(distanceFromStop: JsonField) = apply { + this.distanceFromStop = distanceFromStop + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun frequency(frequency: JsonField) = apply { this.frequency = frequency } + + /** Historical occupancy information of the transit vehicle. */ + fun historicalOccupancy(historicalOccupancy: String) = + historicalOccupancy(JsonField.of(historicalOccupancy)) + + /** + * Sets [Builder.historicalOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.historicalOccupancy] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun historicalOccupancy(historicalOccupancy: JsonField) = apply { + this.historicalOccupancy = historicalOccupancy + } + + /** Timestamp of the last update time for this arrival. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun predicted(predicted: JsonField) = apply { this.predicted = predicted } + + /** Interval for predicted arrival time, if available. */ + fun predictedArrivalInterval(predictedArrivalInterval: String) = + predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) + + /** + * Sets [Builder.predictedArrivalInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedArrivalInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = apply { + this.predictedArrivalInterval = predictedArrivalInterval + } + + /** Interval for predicted departure time, if available. */ + fun predictedDepartureInterval(predictedDepartureInterval: String) = + predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) + + /** + * Sets [Builder.predictedDepartureInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedDepartureInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = + apply { + this.predictedDepartureInterval = predictedDepartureInterval + } + + /** Predicted occupancy status of the transit vehicle. */ + fun predictedOccupancy(predictedOccupancy: String) = + predictedOccupancy(JsonField.of(predictedOccupancy)) + + /** + * Sets [Builder.predictedOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedOccupancy] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun predictedOccupancy(predictedOccupancy: JsonField) = apply { + this.predictedOccupancy = predictedOccupancy + } + + /** + * Optional route long name that potentially overrides the route long name in the + * referenced route element. + */ + fun routeLongName(routeLongName: String) = + routeLongName(JsonField.of(routeLongName)) + + /** + * Sets [Builder.routeLongName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeLongName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeLongName(routeLongName: JsonField) = apply { + this.routeLongName = routeLongName + } + + /** + * Optional route short name that potentially overrides the route short name in the + * referenced route element. + */ + fun routeShortName(routeShortName: String) = + routeShortName(JsonField.of(routeShortName)) + + /** + * Sets [Builder.routeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeShortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeShortName(routeShortName: JsonField) = apply { + this.routeShortName = routeShortName + } + + /** Interval for scheduled arrival time. */ + fun scheduledArrivalInterval(scheduledArrivalInterval: String) = + scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) + + /** + * Sets [Builder.scheduledArrivalInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledArrivalInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = apply { + this.scheduledArrivalInterval = scheduledArrivalInterval + } + + /** Interval for scheduled departure time. */ + fun scheduledDepartureInterval(scheduledDepartureInterval: String) = + scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) + + /** + * Sets [Builder.scheduledDepartureInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDepartureInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = + apply { + this.scheduledDepartureInterval = scheduledDepartureInterval + } + + /** Scheduled track information of the arriving transit vehicle. */ + fun scheduledTrack(scheduledTrack: String) = + scheduledTrack(JsonField.of(scheduledTrack)) + + /** + * Sets [Builder.scheduledTrack] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledTrack] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scheduledTrack(scheduledTrack: JsonField) = apply { + this.scheduledTrack = scheduledTrack + } + + /** References to situation elements (if any) applicable to this arrival. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** Current status of the arrival. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Trip-specific status for the arriving transit vehicle. */ + fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) + + /** + * Sets [Builder.tripStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.tripStatus] with a well-typed [TripStatus] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripStatus(tripStatus: JsonField) = apply { + this.tripStatus = tripStatus + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .blockTripSequence() + * .departureEnabled() + * .numberOfStopsAway() + * .predictedArrivalTime() + * .predictedDepartureTime() + * .routeId() + * .scheduledArrivalTime() + * .scheduledDepartureTime() + * .serviceDate() + * .stopId() + * .stopSequence() + * .totalStopsInTrip() + * .tripHeadsign() + * .tripId() + * .vehicleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("departureEnabled", departureEnabled), + checkRequired("numberOfStopsAway", numberOfStopsAway), + checkRequired("predictedArrivalTime", predictedArrivalTime), + checkRequired("predictedDepartureTime", predictedDepartureTime), + checkRequired("routeId", routeId), + checkRequired("scheduledArrivalTime", scheduledArrivalTime), + checkRequired("scheduledDepartureTime", scheduledDepartureTime), + checkRequired("serviceDate", serviceDate), + checkRequired("stopId", stopId), + checkRequired("stopSequence", stopSequence), + checkRequired("totalStopsInTrip", totalStopsInTrip), + checkRequired("tripHeadsign", tripHeadsign), + checkRequired("tripId", tripId), + checkRequired("vehicleId", vehicleId), + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + status, + tripStatus, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + arrivalEnabled() + blockTripSequence() + departureEnabled() + numberOfStopsAway() + predictedArrivalTime() + predictedDepartureTime() + routeId() + scheduledArrivalTime() + scheduledDepartureTime() + serviceDate() + stopId() + stopSequence() + totalStopsInTrip() + tripHeadsign() + tripId() + vehicleId() + actualTrack() + distanceFromStop() + frequency() + historicalOccupancy() + lastUpdateTime() + occupancyStatus() + predicted() + predictedArrivalInterval() + predictedDepartureInterval() + predictedOccupancy() + routeLongName() + routeShortName() + scheduledArrivalInterval() + scheduledDepartureInterval() + scheduledTrack() + situationIds() + status() + tripStatus().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (departureEnabled.asKnown().isPresent) 1 else 0) + + (if (numberOfStopsAway.asKnown().isPresent) 1 else 0) + + (if (predictedArrivalTime.asKnown().isPresent) 1 else 0) + + (if (predictedDepartureTime.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (scheduledArrivalTime.asKnown().isPresent) 1 else 0) + + (if (scheduledDepartureTime.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (stopSequence.asKnown().isPresent) 1 else 0) + + (if (totalStopsInTrip.asKnown().isPresent) 1 else 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + (if (actualTrack.asKnown().isPresent) 1 else 0) + + (if (distanceFromStop.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (predictedArrivalInterval.asKnown().isPresent) 1 else 0) + + (if (predictedDepartureInterval.asKnown().isPresent) 1 else 0) + + (if (predictedOccupancy.asKnown().isPresent) 1 else 0) + + (if (routeLongName.asKnown().isPresent) 1 else 0) + + (if (routeShortName.asKnown().isPresent) 1 else 0) + + (if (scheduledArrivalInterval.asKnown().isPresent) 1 else 0) + + (if (scheduledDepartureInterval.asKnown().isPresent) 1 else 0) + + (if (scheduledTrack.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (tripStatus.asKnown().getOrNull()?.validity() ?: 0) + + /** Trip-specific status for the arriving transit vehicle. */ + class TripStatus + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownLocation(): Optional = + lastKnownLocation.getOptional("lastKnownLocation") + + /** + * Last known orientation value received in real-time from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownOrientation(): Optional = + lastKnownOrientation.getOptional("lastKnownOrientation") + + /** + * ID of the next stop the transit vehicle is scheduled to arrive at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStop(): Optional = nextStop.getOptional("nextStop") + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStopTimeOffset(): Optional = + nextStopTimeOffset.getOptional("nextStopTimeOffset") + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("orientation") + + /** + * Current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDistanceAlongTrip(): Optional = + scheduledDistanceAlongTrip.getOptional("scheduledDistanceAlongTrip") + + /** + * References to situation elements (if any) applicable to this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * ID of the transit vehicle currently serving the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vehicleId(): Optional = vehicleId.getOptional("vehicleId") + + /** + * Returns the raw JSON value of [activeTripId]. + * + * Unlike [activeTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [closestStop]. + * + * Unlike [closestStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [lastKnownDistanceAlongTrip]. + * + * Unlike [lastKnownDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [scheduleDeviation]. + * + * Unlike [scheduleDeviation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduleDeviation") + @ExcludeMissing + fun _scheduleDeviation(): JsonField = scheduleDeviation + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [totalDistanceAlongTrip]. + * + * Unlike [totalDistanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Returns the raw JSON value of [closestStopTimeOffset]. + * + * Unlike [closestStopTimeOffset], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [lastKnownLocation]. + * + * Unlike [lastKnownLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Returns the raw JSON value of [lastKnownOrientation]. + * + * Unlike [lastKnownOrientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** + * Returns the raw JSON value of [nextStop]. + * + * Unlike [nextStop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Returns the raw JSON value of [nextStopTimeOffset]. + * + * Unlike [nextStopTimeOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [scheduledDistanceAlongTrip]. + * + * Unlike [scheduledDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripStatus]. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripStatus]. */ + class Builder internal constructor() { + + private var activeTripId: JsonField? = null + private var blockTripSequence: JsonField? = null + private var closestStop: JsonField? = null + private var distanceAlongTrip: JsonField? = null + private var lastKnownDistanceAlongTrip: JsonField? = null + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var occupancyCapacity: JsonField? = null + private var occupancyCount: JsonField? = null + private var occupancyStatus: JsonField? = null + private var phase: JsonField? = null + private var predicted: JsonField? = null + private var scheduleDeviation: JsonField? = null + private var serviceDate: JsonField? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null + private var closestStopTimeOffset: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var lastKnownLocation: JsonField = JsonMissing.of() + private var lastKnownOrientation: JsonField = JsonMissing.of() + private var nextStop: JsonField = JsonMissing.of() + private var nextStopTimeOffset: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var vehicleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tripStatus: TripStatus) = apply { + activeTripId = tripStatus.activeTripId + blockTripSequence = tripStatus.blockTripSequence + closestStop = tripStatus.closestStop + distanceAlongTrip = tripStatus.distanceAlongTrip + lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip + lastLocationUpdateTime = tripStatus.lastLocationUpdateTime + lastUpdateTime = tripStatus.lastUpdateTime + occupancyCapacity = tripStatus.occupancyCapacity + occupancyCount = tripStatus.occupancyCount + occupancyStatus = tripStatus.occupancyStatus + phase = tripStatus.phase + predicted = tripStatus.predicted + scheduleDeviation = tripStatus.scheduleDeviation + serviceDate = tripStatus.serviceDate + status = tripStatus.status + totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip + closestStopTimeOffset = tripStatus.closestStopTimeOffset + frequency = tripStatus.frequency + lastKnownLocation = tripStatus.lastKnownLocation + lastKnownOrientation = tripStatus.lastKnownOrientation + nextStop = tripStatus.nextStop + nextStopTimeOffset = tripStatus.nextStopTimeOffset + orientation = tripStatus.orientation + position = tripStatus.position + scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip + situationIds = tripStatus.situationIds.map { it.toMutableList() } + vehicleId = tripStatus.vehicleId + additionalProperties = tripStatus.additionalProperties.toMutableMap() + } + + /** Trip ID of the trip the vehicle is actively serving. */ + fun activeTripId(activeTripId: String) = + activeTripId(JsonField.of(activeTripId)) + + /** + * Sets [Builder.activeTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.activeTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun activeTripId(activeTripId: JsonField) = apply { + this.activeTripId = activeTripId + } + + /** Index of the active trip into the sequence of trips for the active block. */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** ID of the closest stop to the current location of the transit vehicle. */ + fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) + + /** + * Sets [Builder.closestStop] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStop(closestStop: JsonField) = apply { + this.closestStop = closestStop + } + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + */ + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = + lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) + + /** + * Sets [Builder.lastKnownDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = + apply { + this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip + } + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + /** Timestamp of the last known real-time update from the transit vehicle. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Capacity of the transit vehicle in terms of occupancy. */ + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + /** Current count of occupants in the transit vehicle. */ + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Current journey phase of the trip. */ + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + */ + fun scheduleDeviation(scheduleDeviation: Long) = + scheduleDeviation(JsonField.of(scheduleDeviation)) + + /** + * Sets [Builder.scheduleDeviation] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDeviation] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduleDeviation(scheduleDeviation: JsonField) = apply { + this.scheduleDeviation = scheduleDeviation + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** Current status modifiers for the trip. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total length of the trip, in meters. */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = + totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) + + /** + * Sets [Builder.totalDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDistanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { + this.totalDistanceAlongTrip = totalDistanceAlongTrip + } + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(closestStopTimeOffset: Long) = + closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) + + /** + * Sets [Builder.closestStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { + this.closestStopTimeOffset = closestStopTimeOffset + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownLocation] with a well-typed + * [LastKnownLocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownLocation(lastKnownLocation: JsonField) = apply { + this.lastKnownLocation = lastKnownLocation + } + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + fun lastKnownOrientation(lastKnownOrientation: Double) = + lastKnownOrientation(JsonField.of(lastKnownOrientation)) + + /** + * Sets [Builder.lastKnownOrientation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownOrientation] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { + this.lastKnownOrientation = lastKnownOrientation + } + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) + + /** + * Sets [Builder.nextStop] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + fun nextStopTimeOffset(nextStopTimeOffset: Long) = + nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) + + /** + * Sets [Builder.nextStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStopTimeOffset] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { + this.nextStopTimeOffset = nextStopTimeOffset + } + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = + scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) + + /** + * Sets [Builder.scheduledDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripStatus = + TripStatus( + checkRequired("activeTripId", activeTripId), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("closestStop", closestStop), + checkRequired("distanceAlongTrip", distanceAlongTrip), + checkRequired("lastKnownDistanceAlongTrip", lastKnownDistanceAlongTrip), + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("occupancyCapacity", occupancyCapacity), + checkRequired("occupancyCount", occupancyCount), + checkRequired("occupancyStatus", occupancyStatus), + checkRequired("phase", phase), + checkRequired("predicted", predicted), + checkRequired("scheduleDeviation", scheduleDeviation), + checkRequired("serviceDate", serviceDate), + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + vehicleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripStatus = apply { + if (validated) { + return@apply + } + + activeTripId() + blockTripSequence() + closestStop() + distanceAlongTrip() + lastKnownDistanceAlongTrip() + lastLocationUpdateTime() + lastUpdateTime() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + predicted() + scheduleDeviation() + serviceDate() + status() + totalDistanceAlongTrip() + closestStopTimeOffset() + frequency() + lastKnownLocation().ifPresent { it.validate() } + lastKnownOrientation() + nextStop() + nextStopTimeOffset() + orientation() + position().ifPresent { it.validate() } + scheduledDistanceAlongTrip() + situationIds() + vehicleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (activeTripId.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (closestStop.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastKnownDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (scheduleDeviation.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (totalDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (closestStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (lastKnownLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastKnownOrientation.asKnown().isPresent) 1 else 0) + + (if (nextStop.asKnown().isPresent) 1 else 0) + + (if (nextStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + + (if (scheduledDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + /** Last known location of the transit vehicle. */ + class LastKnownLocation + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && distanceAlongTrip == other.distanceAlongTrip && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && serviceDate == other.serviceDate && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && closestStopTimeOffset == other.closestStopTimeOffset && frequency == other.frequency && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && orientation == other.orientation && position == other.position && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && situationIds == other.situationIds && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, distanceAlongTrip, lastKnownDistanceAlongTrip, lastLocationUpdateTime, lastUpdateTime, occupancyCapacity, occupancyCount, occupancyStatus, phase, predicted, scheduleDeviation, serviceDate, status, totalDistanceAlongTrip, closestStopTimeOffset, frequency, lastKnownLocation, lastKnownOrientation, nextStop, nextStopTimeOffset, orientation, position, scheduledDistanceAlongTrip, situationIds, vehicleId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && arrivalEnabled == other.arrivalEnabled && blockTripSequence == other.blockTripSequence && departureEnabled == other.departureEnabled && numberOfStopsAway == other.numberOfStopsAway && predictedArrivalTime == other.predictedArrivalTime && predictedDepartureTime == other.predictedDepartureTime && routeId == other.routeId && scheduledArrivalTime == other.scheduledArrivalTime && scheduledDepartureTime == other.scheduledDepartureTime && serviceDate == other.serviceDate && stopId == other.stopId && stopSequence == other.stopSequence && totalStopsInTrip == other.totalStopsInTrip && tripHeadsign == other.tripHeadsign && tripId == other.tripId && vehicleId == other.vehicleId && actualTrack == other.actualTrack && distanceFromStop == other.distanceFromStop && frequency == other.frequency && historicalOccupancy == other.historicalOccupancy && lastUpdateTime == other.lastUpdateTime && occupancyStatus == other.occupancyStatus && predicted == other.predicted && predictedArrivalInterval == other.predictedArrivalInterval && predictedDepartureInterval == other.predictedDepartureInterval && predictedOccupancy == other.predictedOccupancy && routeLongName == other.routeLongName && routeShortName == other.routeShortName && scheduledArrivalInterval == other.scheduledArrivalInterval && scheduledDepartureInterval == other.scheduledDepartureInterval && scheduledTrack == other.scheduledTrack && situationIds == other.situationIds && status == other.status && tripStatus == other.tripStatus && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, blockTripSequence, departureEnabled, numberOfStopsAway, predictedArrivalTime, predictedDepartureTime, routeId, scheduledArrivalTime, scheduledDepartureTime, serviceDate, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, vehicleId, actualTrack, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, occupancyStatus, predicted, predictedArrivalInterval, predictedDepartureInterval, predictedOccupancy, routeLongName, routeShortName, scheduledArrivalInterval, scheduledDepartureInterval, scheduledTrack, situationIds, status, tripStatus, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, numberOfStopsAway=$numberOfStopsAway, predictedArrivalTime=$predictedArrivalTime, predictedDepartureTime=$predictedDepartureTime, routeId=$routeId, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureTime=$scheduledDepartureTime, serviceDate=$serviceDate, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, vehicleId=$vehicleId, actualTrack=$actualTrack, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedDepartureInterval=$predictedDepartureInterval, predictedOccupancy=$predictedOccupancy, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledTrack=$scheduledTrack, situationIds=$situationIds, status=$status, tripStatus=$tripStatus, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ArrivalAndDepartureRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ArrivalAndDepartureRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveParams.kt new file mode 100644 index 0000000..9f940f7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveParams.kt @@ -0,0 +1,184 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is BlockRetrieveParams && blockId == other.blockId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(blockId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "BlockRetrieveParams{blockId=$blockId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt new file mode 100644 index 0000000..e7dfe35 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt @@ -0,0 +1,1985 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.block + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class BlockRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BlockRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BlockRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blockRetrieveResponse: BlockRetrieveResponse) = apply { + code = blockRetrieveResponse.code + currentTime = blockRetrieveResponse.currentTime + text = blockRetrieveResponse.text + version = blockRetrieveResponse.version + data = blockRetrieveResponse.data + additionalProperties = blockRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BlockRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BlockRetrieveResponse = + BlockRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BlockRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val id: JsonField, + private val configurations: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("configurations") + @ExcludeMissing + configurations: JsonField> = JsonMissing.of(), + ) : this(id, configurations, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun configurations(): List = configurations.getRequired("configurations") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [configurations]. + * + * Unlike [configurations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("configurations") + @ExcludeMissing + fun _configurations(): JsonField> = configurations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .id() + * .configurations() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var configurations: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + configurations = entry.configurations.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun configurations(configurations: List) = + configurations(JsonField.of(configurations)) + + /** + * Sets [Builder.configurations] to an arbitrary JSON value. + * + * You should usually call [Builder.configurations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun configurations(configurations: JsonField>) = apply { + this.configurations = configurations.map { it.toMutableList() } + } + + /** + * Adds a single [Configuration] to [configurations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConfiguration(configuration: Configuration) = apply { + configurations = + (configurations ?: JsonField.of(mutableListOf())).also { + checkKnown("configurations", it).add(configuration) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .configurations() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("configurations", configurations).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + configurations().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (configurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Configuration + private constructor( + private val activeServiceIds: JsonField>, + private val trips: JsonField>, + private val inactiveServiceIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeServiceIds") + @ExcludeMissing + activeServiceIds: JsonField> = JsonMissing.of(), + @JsonProperty("trips") + @ExcludeMissing + trips: JsonField> = JsonMissing.of(), + @JsonProperty("inactiveServiceIds") + @ExcludeMissing + inactiveServiceIds: JsonField> = JsonMissing.of(), + ) : this(activeServiceIds, trips, inactiveServiceIds, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeServiceIds(): List = + activeServiceIds.getRequired("activeServiceIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun trips(): List = trips.getRequired("trips") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun inactiveServiceIds(): Optional> = + inactiveServiceIds.getOptional("inactiveServiceIds") + + /** + * Returns the raw JSON value of [activeServiceIds]. + * + * Unlike [activeServiceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeServiceIds") + @ExcludeMissing + fun _activeServiceIds(): JsonField> = activeServiceIds + + /** + * Returns the raw JSON value of [trips]. + * + * Unlike [trips], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips + + /** + * Returns the raw JSON value of [inactiveServiceIds]. + * + * Unlike [inactiveServiceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inactiveServiceIds") + @ExcludeMissing + fun _inactiveServiceIds(): JsonField> = inactiveServiceIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Configuration]. + * + * The following fields are required: + * ```java + * .activeServiceIds() + * .trips() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Configuration]. */ + class Builder internal constructor() { + + private var activeServiceIds: JsonField>? = null + private var trips: JsonField>? = null + private var inactiveServiceIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(configuration: Configuration) = apply { + activeServiceIds = configuration.activeServiceIds.map { it.toMutableList() } + trips = configuration.trips.map { it.toMutableList() } + inactiveServiceIds = + configuration.inactiveServiceIds.map { it.toMutableList() } + additionalProperties = configuration.additionalProperties.toMutableMap() + } + + fun activeServiceIds(activeServiceIds: List) = + activeServiceIds(JsonField.of(activeServiceIds)) + + /** + * Sets [Builder.activeServiceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.activeServiceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun activeServiceIds(activeServiceIds: JsonField>) = apply { + this.activeServiceIds = activeServiceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [activeServiceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addActiveServiceId(activeServiceId: String) = apply { + activeServiceIds = + (activeServiceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("activeServiceIds", it).add(activeServiceId) + } + } + + fun trips(trips: List) = trips(JsonField.of(trips)) + + /** + * Sets [Builder.trips] to an arbitrary JSON value. + * + * You should usually call [Builder.trips] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun trips(trips: JsonField>) = apply { + this.trips = trips.map { it.toMutableList() } + } + + /** + * Adds a single [Trip] to [trips]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrip(trip: Trip) = apply { + trips = + (trips ?: JsonField.of(mutableListOf())).also { + checkKnown("trips", it).add(trip) + } + } + + fun inactiveServiceIds(inactiveServiceIds: List) = + inactiveServiceIds(JsonField.of(inactiveServiceIds)) + + /** + * Sets [Builder.inactiveServiceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.inactiveServiceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun inactiveServiceIds(inactiveServiceIds: JsonField>) = apply { + this.inactiveServiceIds = inactiveServiceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [inactiveServiceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInactiveServiceId(inactiveServiceId: String) = apply { + inactiveServiceIds = + (inactiveServiceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("inactiveServiceIds", it).add(inactiveServiceId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Configuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeServiceIds() + * .trips() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Configuration = + Configuration( + checkRequired("activeServiceIds", activeServiceIds).map { + it.toImmutable() + }, + checkRequired("trips", trips).map { it.toImmutable() }, + (inactiveServiceIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Configuration = apply { + if (validated) { + return@apply + } + + activeServiceIds() + trips().forEach { it.validate() } + inactiveServiceIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (activeServiceIds.asKnown().getOrNull()?.size ?: 0) + + (trips.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (inactiveServiceIds.asKnown().getOrNull()?.size ?: 0) + + class Trip + private constructor( + private val accumulatedSlackTime: JsonField, + private val blockStopTimes: JsonField>, + private val distanceAlongBlock: JsonField, + private val tripId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + accumulatedSlackTime: JsonField = JsonMissing.of(), + @JsonProperty("blockStopTimes") + @ExcludeMissing + blockStopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + distanceAlongBlock: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + ) : this( + accumulatedSlackTime, + blockStopTimes, + distanceAlongBlock, + tripId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun accumulatedSlackTime(): Float = + accumulatedSlackTime.getRequired("accumulatedSlackTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun blockStopTimes(): List = + blockStopTimes.getRequired("blockStopTimes") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun distanceAlongBlock(): Float = + distanceAlongBlock.getRequired("distanceAlongBlock") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * Returns the raw JSON value of [accumulatedSlackTime]. + * + * Unlike [accumulatedSlackTime], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + fun _accumulatedSlackTime(): JsonField = accumulatedSlackTime + + /** + * Returns the raw JSON value of [blockStopTimes]. + * + * Unlike [blockStopTimes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockStopTimes") + @ExcludeMissing + fun _blockStopTimes(): JsonField> = blockStopTimes + + /** + * Returns the raw JSON value of [distanceAlongBlock]. + * + * Unlike [distanceAlongBlock], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + fun _distanceAlongBlock(): JsonField = distanceAlongBlock + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Trip]. + * + * The following fields are required: + * ```java + * .accumulatedSlackTime() + * .blockStopTimes() + * .distanceAlongBlock() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Trip]. */ + class Builder internal constructor() { + + private var accumulatedSlackTime: JsonField? = null + private var blockStopTimes: JsonField>? = null + private var distanceAlongBlock: JsonField? = null + private var tripId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(trip: Trip) = apply { + accumulatedSlackTime = trip.accumulatedSlackTime + blockStopTimes = trip.blockStopTimes.map { it.toMutableList() } + distanceAlongBlock = trip.distanceAlongBlock + tripId = trip.tripId + additionalProperties = trip.additionalProperties.toMutableMap() + } + + fun accumulatedSlackTime(accumulatedSlackTime: Float) = + accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) + + /** + * Sets [Builder.accumulatedSlackTime] to an arbitrary JSON value. + * + * You should usually call [Builder.accumulatedSlackTime] with a well-typed + * [Float] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = apply { + this.accumulatedSlackTime = accumulatedSlackTime + } + + fun blockStopTimes(blockStopTimes: List) = + blockStopTimes(JsonField.of(blockStopTimes)) + + /** + * Sets [Builder.blockStopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.blockStopTimes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun blockStopTimes(blockStopTimes: JsonField>) = apply { + this.blockStopTimes = blockStopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [BlockStopTime] to [blockStopTimes]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addBlockStopTime(blockStopTime: BlockStopTime) = apply { + blockStopTimes = + (blockStopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("blockStopTimes", it).add(blockStopTime) + } + } + + fun distanceAlongBlock(distanceAlongBlock: Float) = + distanceAlongBlock(JsonField.of(distanceAlongBlock)) + + /** + * Sets [Builder.distanceAlongBlock] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongBlock] with a well-typed + * [Float] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { + this.distanceAlongBlock = distanceAlongBlock + } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Trip]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accumulatedSlackTime() + * .blockStopTimes() + * .distanceAlongBlock() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Trip = + Trip( + checkRequired("accumulatedSlackTime", accumulatedSlackTime), + checkRequired("blockStopTimes", blockStopTimes).map { + it.toImmutable() + }, + checkRequired("distanceAlongBlock", distanceAlongBlock), + checkRequired("tripId", tripId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Trip = apply { + if (validated) { + return@apply + } + + accumulatedSlackTime() + blockStopTimes().forEach { it.validate() } + distanceAlongBlock() + tripId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accumulatedSlackTime.asKnown().isPresent) 1 else 0) + + (blockStopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (distanceAlongBlock.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + class BlockStopTime + private constructor( + private val accumulatedSlackTime: JsonField, + private val blockSequence: JsonField, + private val distanceAlongBlock: JsonField, + private val stopTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + accumulatedSlackTime: JsonField = JsonMissing.of(), + @JsonProperty("blockSequence") + @ExcludeMissing + blockSequence: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + distanceAlongBlock: JsonField = JsonMissing.of(), + @JsonProperty("stopTime") + @ExcludeMissing + stopTime: JsonField = JsonMissing.of(), + ) : this( + accumulatedSlackTime, + blockSequence, + distanceAlongBlock, + stopTime, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun accumulatedSlackTime(): Float = + accumulatedSlackTime.getRequired("accumulatedSlackTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun blockSequence(): Long = blockSequence.getRequired("blockSequence") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun distanceAlongBlock(): Float = + distanceAlongBlock.getRequired("distanceAlongBlock") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun stopTime(): StopTime = stopTime.getRequired("stopTime") + + /** + * Returns the raw JSON value of [accumulatedSlackTime]. + * + * Unlike [accumulatedSlackTime], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + fun _accumulatedSlackTime(): JsonField = accumulatedSlackTime + + /** + * Returns the raw JSON value of [blockSequence]. + * + * Unlike [blockSequence], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("blockSequence") + @ExcludeMissing + fun _blockSequence(): JsonField = blockSequence + + /** + * Returns the raw JSON value of [distanceAlongBlock]. + * + * Unlike [distanceAlongBlock], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + fun _distanceAlongBlock(): JsonField = distanceAlongBlock + + /** + * Returns the raw JSON value of [stopTime]. + * + * Unlike [stopTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopTime") + @ExcludeMissing + fun _stopTime(): JsonField = stopTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BlockStopTime]. + * + * The following fields are required: + * ```java + * .accumulatedSlackTime() + * .blockSequence() + * .distanceAlongBlock() + * .stopTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BlockStopTime]. */ + class Builder internal constructor() { + + private var accumulatedSlackTime: JsonField? = null + private var blockSequence: JsonField? = null + private var distanceAlongBlock: JsonField? = null + private var stopTime: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(blockStopTime: BlockStopTime) = apply { + accumulatedSlackTime = blockStopTime.accumulatedSlackTime + blockSequence = blockStopTime.blockSequence + distanceAlongBlock = blockStopTime.distanceAlongBlock + stopTime = blockStopTime.stopTime + additionalProperties = + blockStopTime.additionalProperties.toMutableMap() + } + + fun accumulatedSlackTime(accumulatedSlackTime: Float) = + accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) + + /** + * Sets [Builder.accumulatedSlackTime] to an arbitrary JSON value. + * + * You should usually call [Builder.accumulatedSlackTime] with a + * well-typed [Float] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = + apply { + this.accumulatedSlackTime = accumulatedSlackTime + } + + fun blockSequence(blockSequence: Long) = + blockSequence(JsonField.of(blockSequence)) + + /** + * Sets [Builder.blockSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockSequence] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun blockSequence(blockSequence: JsonField) = apply { + this.blockSequence = blockSequence + } + + fun distanceAlongBlock(distanceAlongBlock: Float) = + distanceAlongBlock(JsonField.of(distanceAlongBlock)) + + /** + * Sets [Builder.distanceAlongBlock] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongBlock] with a + * well-typed [Float] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { + this.distanceAlongBlock = distanceAlongBlock + } + + fun stopTime(stopTime: StopTime) = stopTime(JsonField.of(stopTime)) + + /** + * Sets [Builder.stopTime] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTime] with a well-typed + * [StopTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTime(stopTime: JsonField) = apply { + this.stopTime = stopTime + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BlockStopTime]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .accumulatedSlackTime() + * .blockSequence() + * .distanceAlongBlock() + * .stopTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BlockStopTime = + BlockStopTime( + checkRequired("accumulatedSlackTime", accumulatedSlackTime), + checkRequired("blockSequence", blockSequence), + checkRequired("distanceAlongBlock", distanceAlongBlock), + checkRequired("stopTime", stopTime), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BlockStopTime = apply { + if (validated) { + return@apply + } + + accumulatedSlackTime() + blockSequence() + distanceAlongBlock() + stopTime().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accumulatedSlackTime.asKnown().isPresent) 1 else 0) + + (if (blockSequence.asKnown().isPresent) 1 else 0) + + (if (distanceAlongBlock.asKnown().isPresent) 1 else 0) + + (stopTime.asKnown().getOrNull()?.validity() ?: 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val stopId: JsonField, + private val dropOffType: JsonField, + private val pickupType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("dropOffType") + @ExcludeMissing + dropOffType: JsonField = JsonMissing.of(), + @JsonProperty("pickupType") + @ExcludeMissing + pickupType: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + stopId, + dropOffType, + pickupType, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun departureTime(): Long = departureTime.getRequired("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun dropOffType(): Optional = + dropOffType.getOptional("dropOffType") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun pickupType(): Optional = pickupType.getOptional("pickupType") + + /** + * Returns the raw JSON value of [arrivalTime]. + * + * Unlike [arrivalTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime + + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId + + /** + * Returns the raw JSON value of [dropOffType]. + * + * Unlike [dropOffType], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dropOffType") + @ExcludeMissing + fun _dropOffType(): JsonField = dropOffType + + /** + * Returns the raw JSON value of [pickupType]. + * + * Unlike [pickupType], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("pickupType") + @ExcludeMissing + fun _pickupType(): JsonField = pickupType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [StopTime]. + * + * The following fields are required: + * ```java + * .arrivalTime() + * .departureTime() + * .stopId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField? = null + private var departureTime: JsonField? = null + private var stopId: JsonField? = null + private var dropOffType: JsonField = JsonMissing.of() + private var pickupType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + stopId = stopTime.stopId + dropOffType = stopTime.dropOffType + pickupType = stopTime.pickupType + additionalProperties = + stopTime.additionalProperties.toMutableMap() + } + + fun arrivalTime(arrivalTime: Long) = + arrivalTime(JsonField.of(arrivalTime)) + + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } + + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) + + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { + this.stopId = stopId + } + + fun dropOffType(dropOffType: Long) = + dropOffType(JsonField.of(dropOffType)) + + /** + * Sets [Builder.dropOffType] to an arbitrary JSON value. + * + * You should usually call [Builder.dropOffType] with a well-typed + * [Long] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dropOffType(dropOffType: JsonField) = apply { + this.dropOffType = dropOffType + } + + fun pickupType(pickupType: Long) = + pickupType(JsonField.of(pickupType)) + + /** + * Sets [Builder.pickupType] to an arbitrary JSON value. + * + * You should usually call [Builder.pickupType] with a well-typed + * [Long] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pickupType(pickupType: JsonField) = apply { + this.pickupType = pickupType + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .arrivalTime() + * .departureTime() + * .stopId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopTime = + StopTime( + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureTime", departureTime), + checkRequired("stopId", stopId), + dropOffType, + pickupType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + stopId() + dropOffType() + pickupType() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (dropOffType.asKnown().isPresent) 1 else 0) + + (if (pickupType.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && stopId == other.stopId && dropOffType == other.dropOffType && pickupType == other.pickupType && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, stopId, dropOffType, pickupType, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, stopId=$stopId, dropOffType=$dropOffType, pickupType=$pickupType, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BlockStopTime && accumulatedSlackTime == other.accumulatedSlackTime && blockSequence == other.blockSequence && distanceAlongBlock == other.distanceAlongBlock && stopTime == other.stopTime && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accumulatedSlackTime, blockSequence, distanceAlongBlock, stopTime, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BlockStopTime{accumulatedSlackTime=$accumulatedSlackTime, blockSequence=$blockSequence, distanceAlongBlock=$distanceAlongBlock, stopTime=$stopTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Trip && accumulatedSlackTime == other.accumulatedSlackTime && blockStopTimes == other.blockStopTimes && distanceAlongBlock == other.distanceAlongBlock && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accumulatedSlackTime, blockStopTimes, distanceAlongBlock, tripId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Trip{accumulatedSlackTime=$accumulatedSlackTime, blockStopTimes=$blockStopTimes, distanceAlongBlock=$distanceAlongBlock, tripId=$tripId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Configuration && activeServiceIds == other.activeServiceIds && trips == other.trips && inactiveServiceIds == other.inactiveServiceIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeServiceIds, trips, inactiveServiceIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Configuration{activeServiceIds=$activeServiceIds, trips=$trips, inactiveServiceIds=$inactiveServiceIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && configurations == other.configurations && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, configurations, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, configurations=$configurations, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BlockRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BlockRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveParams.kt new file mode 100644 index 0000000..628f517 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveParams.kt @@ -0,0 +1,166 @@ +// 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 { + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is ConfigRetrieveParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ConfigRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt new file mode 100644 index 0000000..ab640a3 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt @@ -0,0 +1,1731 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.config + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class ConfigRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConfigRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(configRetrieveResponse: ConfigRetrieveResponse) = apply { + code = configRetrieveResponse.code + currentTime = configRetrieveResponse.currentTime + text = configRetrieveResponse.text + version = configRetrieveResponse.version + data = configRetrieveResponse.data + additionalProperties = configRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConfigRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigRetrieveResponse = + ConfigRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConfigRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val id: JsonField, + private val gitProperties: JsonField, + private val name: JsonField, + private val serviceDateFrom: JsonField, + private val serviceDateTo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("gitProperties") + @ExcludeMissing + gitProperties: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("serviceDateFrom") + @ExcludeMissing + serviceDateFrom: JsonField = JsonMissing.of(), + @JsonProperty("serviceDateTo") + @ExcludeMissing + serviceDateTo: JsonField = JsonMissing.of(), + ) : this(id, gitProperties, name, serviceDateFrom, serviceDateTo, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun gitProperties(): Optional = + gitProperties.getOptional("gitProperties") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDateFrom(): Optional = serviceDateFrom.getOptional("serviceDateFrom") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDateTo(): Optional = serviceDateTo.getOptional("serviceDateTo") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [gitProperties]. + * + * Unlike [gitProperties], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitProperties") + @ExcludeMissing + fun _gitProperties(): JsonField = gitProperties + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [serviceDateFrom]. + * + * Unlike [serviceDateFrom], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDateFrom") + @ExcludeMissing + fun _serviceDateFrom(): JsonField = serviceDateFrom + + /** + * Returns the raw JSON value of [serviceDateTo]. + * + * Unlike [serviceDateTo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceDateTo") + @ExcludeMissing + fun _serviceDateTo(): JsonField = serviceDateTo + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Entry]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var gitProperties: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var serviceDateFrom: JsonField = JsonMissing.of() + private var serviceDateTo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + gitProperties = entry.gitProperties + name = entry.name + serviceDateFrom = entry.serviceDateFrom + serviceDateTo = entry.serviceDateTo + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun gitProperties(gitProperties: GitProperties) = + gitProperties(JsonField.of(gitProperties)) + + /** + * Sets [Builder.gitProperties] to an arbitrary JSON value. + * + * You should usually call [Builder.gitProperties] with a well-typed [GitProperties] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun gitProperties(gitProperties: JsonField) = apply { + this.gitProperties = gitProperties + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun serviceDateFrom(serviceDateFrom: String) = + serviceDateFrom(JsonField.of(serviceDateFrom)) + + /** + * Sets [Builder.serviceDateFrom] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDateFrom] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun serviceDateFrom(serviceDateFrom: JsonField) = apply { + this.serviceDateFrom = serviceDateFrom + } + + fun serviceDateTo(serviceDateTo: String) = + serviceDateTo(JsonField.of(serviceDateTo)) + + /** + * Sets [Builder.serviceDateTo] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDateTo] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceDateTo(serviceDateTo: JsonField) = apply { + this.serviceDateTo = serviceDateTo + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Entry = + Entry( + id, + gitProperties, + name, + serviceDateFrom, + serviceDateTo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + gitProperties().ifPresent { it.validate() } + name() + serviceDateFrom() + serviceDateTo() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (gitProperties.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (serviceDateFrom.asKnown().isPresent) 1 else 0) + + (if (serviceDateTo.asKnown().isPresent) 1 else 0) + + class GitProperties + private constructor( + private val gitBranch: JsonField, + private val gitBuildHost: JsonField, + private val gitBuildTime: JsonField, + private val gitBuildUserEmail: JsonField, + private val gitBuildUserName: JsonField, + private val gitBuildVersion: JsonField, + private val gitClosestTagCommitCount: JsonField, + private val gitClosestTagName: JsonField, + private val gitCommitId: JsonField, + private val gitCommitIdAbbrev: JsonField, + private val gitCommitIdDescribe: JsonField, + private val gitCommitIdDescribeShort: JsonField, + private val gitCommitMessageFull: JsonField, + private val gitCommitMessageShort: JsonField, + private val gitCommitTime: JsonField, + private val gitCommitUserEmail: JsonField, + private val gitCommitUserName: JsonField, + private val gitDirty: JsonField, + private val gitRemoteOriginUrl: JsonField, + private val gitTags: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("git.branch") + @ExcludeMissing + gitBranch: JsonField = JsonMissing.of(), + @JsonProperty("git.build.host") + @ExcludeMissing + gitBuildHost: JsonField = JsonMissing.of(), + @JsonProperty("git.build.time") + @ExcludeMissing + gitBuildTime: JsonField = JsonMissing.of(), + @JsonProperty("git.build.user.email") + @ExcludeMissing + gitBuildUserEmail: JsonField = JsonMissing.of(), + @JsonProperty("git.build.user.name") + @ExcludeMissing + gitBuildUserName: JsonField = JsonMissing.of(), + @JsonProperty("git.build.version") + @ExcludeMissing + gitBuildVersion: JsonField = JsonMissing.of(), + @JsonProperty("git.closest.tag.commit.count") + @ExcludeMissing + gitClosestTagCommitCount: JsonField = JsonMissing.of(), + @JsonProperty("git.closest.tag.name") + @ExcludeMissing + gitClosestTagName: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id") + @ExcludeMissing + gitCommitId: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.abbrev") + @ExcludeMissing + gitCommitIdAbbrev: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.describe") + @ExcludeMissing + gitCommitIdDescribe: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.describe-short") + @ExcludeMissing + gitCommitIdDescribeShort: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.message.full") + @ExcludeMissing + gitCommitMessageFull: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.message.short") + @ExcludeMissing + gitCommitMessageShort: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.time") + @ExcludeMissing + gitCommitTime: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.user.email") + @ExcludeMissing + gitCommitUserEmail: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.user.name") + @ExcludeMissing + gitCommitUserName: JsonField = JsonMissing.of(), + @JsonProperty("git.dirty") + @ExcludeMissing + gitDirty: JsonField = JsonMissing.of(), + @JsonProperty("git.remote.origin.url") + @ExcludeMissing + gitRemoteOriginUrl: JsonField = JsonMissing.of(), + @JsonProperty("git.tags") + @ExcludeMissing + gitTags: JsonField = JsonMissing.of(), + ) : this( + gitBranch, + gitBuildHost, + gitBuildTime, + gitBuildUserEmail, + gitBuildUserName, + gitBuildVersion, + gitClosestTagCommitCount, + gitClosestTagName, + gitCommitId, + gitCommitIdAbbrev, + gitCommitIdDescribe, + gitCommitIdDescribeShort, + gitCommitMessageFull, + gitCommitMessageShort, + gitCommitTime, + gitCommitUserEmail, + gitCommitUserName, + gitDirty, + gitRemoteOriginUrl, + gitTags, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBranch(): Optional = gitBranch.getOptional("git.branch") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildHost(): Optional = gitBuildHost.getOptional("git.build.host") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildTime(): Optional = gitBuildTime.getOptional("git.build.time") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildUserEmail(): Optional = + gitBuildUserEmail.getOptional("git.build.user.email") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildUserName(): Optional = + gitBuildUserName.getOptional("git.build.user.name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildVersion(): Optional = + gitBuildVersion.getOptional("git.build.version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitClosestTagCommitCount(): Optional = + gitClosestTagCommitCount.getOptional("git.closest.tag.commit.count") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitClosestTagName(): Optional = + gitClosestTagName.getOptional("git.closest.tag.name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitId(): Optional = gitCommitId.getOptional("git.commit.id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitIdAbbrev(): Optional = + gitCommitIdAbbrev.getOptional("git.commit.id.abbrev") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitIdDescribe(): Optional = + gitCommitIdDescribe.getOptional("git.commit.id.describe") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitIdDescribeShort(): Optional = + gitCommitIdDescribeShort.getOptional("git.commit.id.describe-short") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitMessageFull(): Optional = + gitCommitMessageFull.getOptional("git.commit.message.full") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitMessageShort(): Optional = + gitCommitMessageShort.getOptional("git.commit.message.short") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitTime(): Optional = gitCommitTime.getOptional("git.commit.time") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitUserEmail(): Optional = + gitCommitUserEmail.getOptional("git.commit.user.email") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitUserName(): Optional = + gitCommitUserName.getOptional("git.commit.user.name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitDirty(): Optional = gitDirty.getOptional("git.dirty") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitRemoteOriginUrl(): Optional = + gitRemoteOriginUrl.getOptional("git.remote.origin.url") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitTags(): Optional = gitTags.getOptional("git.tags") + + /** + * Returns the raw JSON value of [gitBranch]. + * + * Unlike [gitBranch], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("git.branch") + @ExcludeMissing + fun _gitBranch(): JsonField = gitBranch + + /** + * Returns the raw JSON value of [gitBuildHost]. + * + * Unlike [gitBuildHost], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.host") + @ExcludeMissing + fun _gitBuildHost(): JsonField = gitBuildHost + + /** + * Returns the raw JSON value of [gitBuildTime]. + * + * Unlike [gitBuildTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.time") + @ExcludeMissing + fun _gitBuildTime(): JsonField = gitBuildTime + + /** + * Returns the raw JSON value of [gitBuildUserEmail]. + * + * Unlike [gitBuildUserEmail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.user.email") + @ExcludeMissing + fun _gitBuildUserEmail(): JsonField = gitBuildUserEmail + + /** + * Returns the raw JSON value of [gitBuildUserName]. + * + * Unlike [gitBuildUserName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.user.name") + @ExcludeMissing + fun _gitBuildUserName(): JsonField = gitBuildUserName + + /** + * Returns the raw JSON value of [gitBuildVersion]. + * + * Unlike [gitBuildVersion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.version") + @ExcludeMissing + fun _gitBuildVersion(): JsonField = gitBuildVersion + + /** + * Returns the raw JSON value of [gitClosestTagCommitCount]. + * + * Unlike [gitClosestTagCommitCount], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("git.closest.tag.commit.count") + @ExcludeMissing + fun _gitClosestTagCommitCount(): JsonField = gitClosestTagCommitCount + + /** + * Returns the raw JSON value of [gitClosestTagName]. + * + * Unlike [gitClosestTagName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.closest.tag.name") + @ExcludeMissing + fun _gitClosestTagName(): JsonField = gitClosestTagName + + /** + * Returns the raw JSON value of [gitCommitId]. + * + * Unlike [gitCommitId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.id") + @ExcludeMissing + fun _gitCommitId(): JsonField = gitCommitId + + /** + * Returns the raw JSON value of [gitCommitIdAbbrev]. + * + * Unlike [gitCommitIdAbbrev], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.id.abbrev") + @ExcludeMissing + fun _gitCommitIdAbbrev(): JsonField = gitCommitIdAbbrev + + /** + * Returns the raw JSON value of [gitCommitIdDescribe]. + * + * Unlike [gitCommitIdDescribe], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.id.describe") + @ExcludeMissing + fun _gitCommitIdDescribe(): JsonField = gitCommitIdDescribe + + /** + * Returns the raw JSON value of [gitCommitIdDescribeShort]. + * + * Unlike [gitCommitIdDescribeShort], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("git.commit.id.describe-short") + @ExcludeMissing + fun _gitCommitIdDescribeShort(): JsonField = gitCommitIdDescribeShort + + /** + * Returns the raw JSON value of [gitCommitMessageFull]. + * + * Unlike [gitCommitMessageFull], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.message.full") + @ExcludeMissing + fun _gitCommitMessageFull(): JsonField = gitCommitMessageFull + + /** + * Returns the raw JSON value of [gitCommitMessageShort]. + * + * Unlike [gitCommitMessageShort], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("git.commit.message.short") + @ExcludeMissing + fun _gitCommitMessageShort(): JsonField = gitCommitMessageShort + + /** + * Returns the raw JSON value of [gitCommitTime]. + * + * Unlike [gitCommitTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.time") + @ExcludeMissing + fun _gitCommitTime(): JsonField = gitCommitTime + + /** + * Returns the raw JSON value of [gitCommitUserEmail]. + * + * Unlike [gitCommitUserEmail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.user.email") + @ExcludeMissing + fun _gitCommitUserEmail(): JsonField = gitCommitUserEmail + + /** + * Returns the raw JSON value of [gitCommitUserName]. + * + * Unlike [gitCommitUserName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.user.name") + @ExcludeMissing + fun _gitCommitUserName(): JsonField = gitCommitUserName + + /** + * Returns the raw JSON value of [gitDirty]. + * + * Unlike [gitDirty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("git.dirty") + @ExcludeMissing + fun _gitDirty(): JsonField = gitDirty + + /** + * Returns the raw JSON value of [gitRemoteOriginUrl]. + * + * Unlike [gitRemoteOriginUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.remote.origin.url") + @ExcludeMissing + fun _gitRemoteOriginUrl(): JsonField = gitRemoteOriginUrl + + /** + * Returns the raw JSON value of [gitTags]. + * + * Unlike [gitTags], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("git.tags") + @ExcludeMissing + fun _gitTags(): JsonField = gitTags + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GitProperties]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitProperties]. */ + class Builder internal constructor() { + + private var gitBranch: JsonField = JsonMissing.of() + private var gitBuildHost: JsonField = JsonMissing.of() + private var gitBuildTime: JsonField = JsonMissing.of() + private var gitBuildUserEmail: JsonField = JsonMissing.of() + private var gitBuildUserName: JsonField = JsonMissing.of() + private var gitBuildVersion: JsonField = JsonMissing.of() + private var gitClosestTagCommitCount: JsonField = JsonMissing.of() + private var gitClosestTagName: JsonField = JsonMissing.of() + private var gitCommitId: JsonField = JsonMissing.of() + private var gitCommitIdAbbrev: JsonField = JsonMissing.of() + private var gitCommitIdDescribe: JsonField = JsonMissing.of() + private var gitCommitIdDescribeShort: JsonField = JsonMissing.of() + private var gitCommitMessageFull: JsonField = JsonMissing.of() + private var gitCommitMessageShort: JsonField = JsonMissing.of() + private var gitCommitTime: JsonField = JsonMissing.of() + private var gitCommitUserEmail: JsonField = JsonMissing.of() + private var gitCommitUserName: JsonField = JsonMissing.of() + private var gitDirty: JsonField = JsonMissing.of() + private var gitRemoteOriginUrl: JsonField = JsonMissing.of() + private var gitTags: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitProperties: GitProperties) = apply { + gitBranch = gitProperties.gitBranch + gitBuildHost = gitProperties.gitBuildHost + gitBuildTime = gitProperties.gitBuildTime + gitBuildUserEmail = gitProperties.gitBuildUserEmail + gitBuildUserName = gitProperties.gitBuildUserName + gitBuildVersion = gitProperties.gitBuildVersion + gitClosestTagCommitCount = gitProperties.gitClosestTagCommitCount + gitClosestTagName = gitProperties.gitClosestTagName + gitCommitId = gitProperties.gitCommitId + gitCommitIdAbbrev = gitProperties.gitCommitIdAbbrev + gitCommitIdDescribe = gitProperties.gitCommitIdDescribe + gitCommitIdDescribeShort = gitProperties.gitCommitIdDescribeShort + gitCommitMessageFull = gitProperties.gitCommitMessageFull + gitCommitMessageShort = gitProperties.gitCommitMessageShort + gitCommitTime = gitProperties.gitCommitTime + gitCommitUserEmail = gitProperties.gitCommitUserEmail + gitCommitUserName = gitProperties.gitCommitUserName + gitDirty = gitProperties.gitDirty + gitRemoteOriginUrl = gitProperties.gitRemoteOriginUrl + gitTags = gitProperties.gitTags + additionalProperties = gitProperties.additionalProperties.toMutableMap() + } + + fun gitBranch(gitBranch: String) = gitBranch(JsonField.of(gitBranch)) + + /** + * Sets [Builder.gitBranch] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBranch] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun gitBranch(gitBranch: JsonField) = apply { + this.gitBranch = gitBranch + } + + fun gitBuildHost(gitBuildHost: String) = + gitBuildHost(JsonField.of(gitBuildHost)) + + /** + * Sets [Builder.gitBuildHost] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildHost] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildHost(gitBuildHost: JsonField) = apply { + this.gitBuildHost = gitBuildHost + } + + fun gitBuildTime(gitBuildTime: String) = + gitBuildTime(JsonField.of(gitBuildTime)) + + /** + * Sets [Builder.gitBuildTime] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildTime] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildTime(gitBuildTime: JsonField) = apply { + this.gitBuildTime = gitBuildTime + } + + fun gitBuildUserEmail(gitBuildUserEmail: String) = + gitBuildUserEmail(JsonField.of(gitBuildUserEmail)) + + /** + * Sets [Builder.gitBuildUserEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildUserEmail] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildUserEmail(gitBuildUserEmail: JsonField) = apply { + this.gitBuildUserEmail = gitBuildUserEmail + } + + fun gitBuildUserName(gitBuildUserName: String) = + gitBuildUserName(JsonField.of(gitBuildUserName)) + + /** + * Sets [Builder.gitBuildUserName] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildUserName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildUserName(gitBuildUserName: JsonField) = apply { + this.gitBuildUserName = gitBuildUserName + } + + fun gitBuildVersion(gitBuildVersion: String) = + gitBuildVersion(JsonField.of(gitBuildVersion)) + + /** + * Sets [Builder.gitBuildVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildVersion] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildVersion(gitBuildVersion: JsonField) = apply { + this.gitBuildVersion = gitBuildVersion + } + + fun gitClosestTagCommitCount(gitClosestTagCommitCount: String) = + gitClosestTagCommitCount(JsonField.of(gitClosestTagCommitCount)) + + /** + * Sets [Builder.gitClosestTagCommitCount] to an arbitrary JSON value. + * + * You should usually call [Builder.gitClosestTagCommitCount] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitClosestTagCommitCount(gitClosestTagCommitCount: JsonField) = + apply { + this.gitClosestTagCommitCount = gitClosestTagCommitCount + } + + fun gitClosestTagName(gitClosestTagName: String) = + gitClosestTagName(JsonField.of(gitClosestTagName)) + + /** + * Sets [Builder.gitClosestTagName] to an arbitrary JSON value. + * + * You should usually call [Builder.gitClosestTagName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitClosestTagName(gitClosestTagName: JsonField) = apply { + this.gitClosestTagName = gitClosestTagName + } + + fun gitCommitId(gitCommitId: String) = gitCommitId(JsonField.of(gitCommitId)) + + /** + * Sets [Builder.gitCommitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitId(gitCommitId: JsonField) = apply { + this.gitCommitId = gitCommitId + } + + fun gitCommitIdAbbrev(gitCommitIdAbbrev: String) = + gitCommitIdAbbrev(JsonField.of(gitCommitIdAbbrev)) + + /** + * Sets [Builder.gitCommitIdAbbrev] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitIdAbbrev] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitIdAbbrev(gitCommitIdAbbrev: JsonField) = apply { + this.gitCommitIdAbbrev = gitCommitIdAbbrev + } + + fun gitCommitIdDescribe(gitCommitIdDescribe: String) = + gitCommitIdDescribe(JsonField.of(gitCommitIdDescribe)) + + /** + * Sets [Builder.gitCommitIdDescribe] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitIdDescribe] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitIdDescribe(gitCommitIdDescribe: JsonField) = apply { + this.gitCommitIdDescribe = gitCommitIdDescribe + } + + fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: String) = + gitCommitIdDescribeShort(JsonField.of(gitCommitIdDescribeShort)) + + /** + * Sets [Builder.gitCommitIdDescribeShort] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitIdDescribeShort] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: JsonField) = + apply { + this.gitCommitIdDescribeShort = gitCommitIdDescribeShort + } + + fun gitCommitMessageFull(gitCommitMessageFull: String) = + gitCommitMessageFull(JsonField.of(gitCommitMessageFull)) + + /** + * Sets [Builder.gitCommitMessageFull] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitMessageFull] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitMessageFull(gitCommitMessageFull: JsonField) = apply { + this.gitCommitMessageFull = gitCommitMessageFull + } + + fun gitCommitMessageShort(gitCommitMessageShort: String) = + gitCommitMessageShort(JsonField.of(gitCommitMessageShort)) + + /** + * Sets [Builder.gitCommitMessageShort] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitMessageShort] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitMessageShort(gitCommitMessageShort: JsonField) = apply { + this.gitCommitMessageShort = gitCommitMessageShort + } + + fun gitCommitTime(gitCommitTime: String) = + gitCommitTime(JsonField.of(gitCommitTime)) + + /** + * Sets [Builder.gitCommitTime] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitTime] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitTime(gitCommitTime: JsonField) = apply { + this.gitCommitTime = gitCommitTime + } + + fun gitCommitUserEmail(gitCommitUserEmail: String) = + gitCommitUserEmail(JsonField.of(gitCommitUserEmail)) + + /** + * Sets [Builder.gitCommitUserEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitUserEmail] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitUserEmail(gitCommitUserEmail: JsonField) = apply { + this.gitCommitUserEmail = gitCommitUserEmail + } + + fun gitCommitUserName(gitCommitUserName: String) = + gitCommitUserName(JsonField.of(gitCommitUserName)) + + /** + * Sets [Builder.gitCommitUserName] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitUserName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitUserName(gitCommitUserName: JsonField) = apply { + this.gitCommitUserName = gitCommitUserName + } + + fun gitDirty(gitDirty: String) = gitDirty(JsonField.of(gitDirty)) + + /** + * Sets [Builder.gitDirty] to an arbitrary JSON value. + * + * You should usually call [Builder.gitDirty] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun gitDirty(gitDirty: JsonField) = apply { this.gitDirty = gitDirty } + + fun gitRemoteOriginUrl(gitRemoteOriginUrl: String) = + gitRemoteOriginUrl(JsonField.of(gitRemoteOriginUrl)) + + /** + * Sets [Builder.gitRemoteOriginUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRemoteOriginUrl] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitRemoteOriginUrl(gitRemoteOriginUrl: JsonField) = apply { + this.gitRemoteOriginUrl = gitRemoteOriginUrl + } + + fun gitTags(gitTags: String) = gitTags(JsonField.of(gitTags)) + + /** + * Sets [Builder.gitTags] to an arbitrary JSON value. + * + * You should usually call [Builder.gitTags] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun gitTags(gitTags: JsonField) = apply { this.gitTags = gitTags } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitProperties]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GitProperties = + GitProperties( + gitBranch, + gitBuildHost, + gitBuildTime, + gitBuildUserEmail, + gitBuildUserName, + gitBuildVersion, + gitClosestTagCommitCount, + gitClosestTagName, + gitCommitId, + gitCommitIdAbbrev, + gitCommitIdDescribe, + gitCommitIdDescribeShort, + gitCommitMessageFull, + gitCommitMessageShort, + gitCommitTime, + gitCommitUserEmail, + gitCommitUserName, + gitDirty, + gitRemoteOriginUrl, + gitTags, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitProperties = apply { + if (validated) { + return@apply + } + + gitBranch() + gitBuildHost() + gitBuildTime() + gitBuildUserEmail() + gitBuildUserName() + gitBuildVersion() + gitClosestTagCommitCount() + gitClosestTagName() + gitCommitId() + gitCommitIdAbbrev() + gitCommitIdDescribe() + gitCommitIdDescribeShort() + gitCommitMessageFull() + gitCommitMessageShort() + gitCommitTime() + gitCommitUserEmail() + gitCommitUserName() + gitDirty() + gitRemoteOriginUrl() + gitTags() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (gitBranch.asKnown().isPresent) 1 else 0) + + (if (gitBuildHost.asKnown().isPresent) 1 else 0) + + (if (gitBuildTime.asKnown().isPresent) 1 else 0) + + (if (gitBuildUserEmail.asKnown().isPresent) 1 else 0) + + (if (gitBuildUserName.asKnown().isPresent) 1 else 0) + + (if (gitBuildVersion.asKnown().isPresent) 1 else 0) + + (if (gitClosestTagCommitCount.asKnown().isPresent) 1 else 0) + + (if (gitClosestTagName.asKnown().isPresent) 1 else 0) + + (if (gitCommitId.asKnown().isPresent) 1 else 0) + + (if (gitCommitIdAbbrev.asKnown().isPresent) 1 else 0) + + (if (gitCommitIdDescribe.asKnown().isPresent) 1 else 0) + + (if (gitCommitIdDescribeShort.asKnown().isPresent) 1 else 0) + + (if (gitCommitMessageFull.asKnown().isPresent) 1 else 0) + + (if (gitCommitMessageShort.asKnown().isPresent) 1 else 0) + + (if (gitCommitTime.asKnown().isPresent) 1 else 0) + + (if (gitCommitUserEmail.asKnown().isPresent) 1 else 0) + + (if (gitCommitUserName.asKnown().isPresent) 1 else 0) + + (if (gitDirty.asKnown().isPresent) 1 else 0) + + (if (gitRemoteOriginUrl.asKnown().isPresent) 1 else 0) + + (if (gitTags.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitProperties && gitBranch == other.gitBranch && gitBuildHost == other.gitBuildHost && gitBuildTime == other.gitBuildTime && gitBuildUserEmail == other.gitBuildUserEmail && gitBuildUserName == other.gitBuildUserName && gitBuildVersion == other.gitBuildVersion && gitClosestTagCommitCount == other.gitClosestTagCommitCount && gitClosestTagName == other.gitClosestTagName && gitCommitId == other.gitCommitId && gitCommitIdAbbrev == other.gitCommitIdAbbrev && gitCommitIdDescribe == other.gitCommitIdDescribe && gitCommitIdDescribeShort == other.gitCommitIdDescribeShort && gitCommitMessageFull == other.gitCommitMessageFull && gitCommitMessageShort == other.gitCommitMessageShort && gitCommitTime == other.gitCommitTime && gitCommitUserEmail == other.gitCommitUserEmail && gitCommitUserName == other.gitCommitUserName && gitDirty == other.gitDirty && gitRemoteOriginUrl == other.gitRemoteOriginUrl && gitTags == other.gitTags && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(gitBranch, gitBuildHost, gitBuildTime, gitBuildUserEmail, gitBuildUserName, gitBuildVersion, gitClosestTagCommitCount, gitClosestTagName, gitCommitId, gitCommitIdAbbrev, gitCommitIdDescribe, gitCommitIdDescribeShort, gitCommitMessageFull, gitCommitMessageShort, gitCommitTime, gitCommitUserEmail, gitCommitUserName, gitDirty, gitRemoteOriginUrl, gitTags, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitProperties{gitBranch=$gitBranch, gitBuildHost=$gitBuildHost, gitBuildTime=$gitBuildTime, gitBuildUserEmail=$gitBuildUserEmail, gitBuildUserName=$gitBuildUserName, gitBuildVersion=$gitBuildVersion, gitClosestTagCommitCount=$gitClosestTagCommitCount, gitClosestTagName=$gitClosestTagName, gitCommitId=$gitCommitId, gitCommitIdAbbrev=$gitCommitIdAbbrev, gitCommitIdDescribe=$gitCommitIdDescribe, gitCommitIdDescribeShort=$gitCommitIdDescribeShort, gitCommitMessageFull=$gitCommitMessageFull, gitCommitMessageShort=$gitCommitMessageShort, gitCommitTime=$gitCommitTime, gitCommitUserEmail=$gitCommitUserEmail, gitCommitUserName=$gitCommitUserName, gitDirty=$gitDirty, gitRemoteOriginUrl=$gitRemoteOriginUrl, gitTags=$gitTags, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && gitProperties == other.gitProperties && name == other.name && serviceDateFrom == other.serviceDateFrom && serviceDateTo == other.serviceDateTo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, gitProperties, name, serviceDateFrom, serviceDateTo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, gitProperties=$gitProperties, name=$name, serviceDateFrom=$serviceDateFrom, serviceDateTo=$serviceDateTo, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ConfigRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConfigRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParams.kt new file mode 100644 index 0000000..807bd94 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParams.kt @@ -0,0 +1,168 @@ +// 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 { + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is CurrentTimeRetrieveParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "CurrentTimeRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt new file mode 100644 index 0000000..c95fdac --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt @@ -0,0 +1,689 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.currenttime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class CurrentTimeRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CurrentTimeRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentTimeRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentTimeRetrieveResponse: CurrentTimeRetrieveResponse) = apply { + code = currentTimeRetrieveResponse.code + currentTime = currentTimeRetrieveResponse.currentTime + text = currentTimeRetrieveResponse.text + version = currentTimeRetrieveResponse.version + data = currentTimeRetrieveResponse.data + additionalProperties = currentTimeRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentTimeRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentTimeRetrieveResponse = + CurrentTimeRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CurrentTimeRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val readableTime: JsonField, + private val time: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("readableTime") + @ExcludeMissing + readableTime: JsonField = JsonMissing.of(), + @JsonProperty("time") @ExcludeMissing time: JsonField = JsonMissing.of(), + ) : this(readableTime, time, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun readableTime(): Optional = readableTime.getOptional("readableTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun time(): Optional = time.getOptional("time") + + /** + * Returns the raw JSON value of [readableTime]. + * + * Unlike [readableTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("readableTime") + @ExcludeMissing + fun _readableTime(): JsonField = readableTime + + /** + * Returns the raw JSON value of [time]. + * + * Unlike [time], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("time") @ExcludeMissing fun _time(): JsonField = time + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Entry]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var readableTime: JsonField = JsonMissing.of() + private var time: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + readableTime = entry.readableTime + time = entry.time + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun readableTime(readableTime: String) = readableTime(JsonField.of(readableTime)) + + /** + * Sets [Builder.readableTime] to an arbitrary JSON value. + * + * You should usually call [Builder.readableTime] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun readableTime(readableTime: JsonField) = apply { + this.readableTime = readableTime + } + + fun time(time: Long) = time(JsonField.of(time)) + + /** + * Sets [Builder.time] to an arbitrary JSON value. + * + * You should usually call [Builder.time] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun time(time: JsonField) = apply { this.time = time } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Entry = Entry(readableTime, time, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + readableTime() + time() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (readableTime.asKnown().isPresent) 1 else 0) + + (if (time.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && readableTime == other.readableTime && time == other.time && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(readableTime, time, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{readableTime=$readableTime, time=$time, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CurrentTimeRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentTimeRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt new file mode 100644 index 0000000..65126fe --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt @@ -0,0 +1,447 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is Code && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReportProblemWithStopRetrieveParams && stopId == other.stopId && code == other.code && userComment == other.userComment && userLat == other.userLat && userLocationAccuracy == other.userLocationAccuracy && userLon == other.userLon && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, code, userComment, userLat, userLocationAccuracy, userLon, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ReportProblemWithStopRetrieveParams{stopId=$stopId, code=$code, userComment=$userComment, userLat=$userLat, userLocationAccuracy=$userLocationAccuracy, userLon=$userLon, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt new file mode 100644 index 0000000..beba906 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt @@ -0,0 +1,541 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is Code && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReportProblemWithTripRetrieveParams && tripId == other.tripId && code == other.code && serviceDate == other.serviceDate && stopId == other.stopId && userComment == other.userComment && userLat == other.userLat && userLocationAccuracy == other.userLocationAccuracy && userLon == other.userLon && userOnVehicle == other.userOnVehicle && userVehicleNumber == other.userVehicleNumber && vehicleId == other.vehicleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(tripId, code, serviceDate, stopId, userComment, userLat, userLocationAccuracy, userLon, userOnVehicle, userVehicleNumber, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ReportProblemWithTripRetrieveParams{tripId=$tripId, code=$code, serviceDate=$serviceDate, stopId=$stopId, userComment=$userComment, userLat=$userLat, userLocationAccuracy=$userLocationAccuracy, userLon=$userLon, userOnVehicle=$userOnVehicle, userVehicleNumber=$userVehicleNumber, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveParams.kt new file mode 100644 index 0000000..dd999b1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveParams.kt @@ -0,0 +1,184 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is RouteRetrieveParams && routeId == other.routeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(routeId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RouteRetrieveParams{routeId=$routeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt new file mode 100644 index 0000000..6a07eea --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt @@ -0,0 +1,1000 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.route + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class RouteRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RouteRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouteRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routeRetrieveResponse: RouteRetrieveResponse) = apply { + code = routeRetrieveResponse.code + currentTime = routeRetrieveResponse.currentTime + text = routeRetrieveResponse.text + version = routeRetrieveResponse.version + data = routeRetrieveResponse.data + additionalProperties = routeRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RouteRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RouteRetrieveResponse = + RouteRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RouteRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Long = type.getRequired("type") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nullSafeShortName") + @ExcludeMissing + fun _nullSafeShortName(): JsonField = nullSafeShortName + + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName + + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var longName: JsonField = JsonMissing.of() + private var nullSafeShortName: JsonField = JsonMissing.of() + private var shortName: JsonField = JsonMissing.of() + private var textColor: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + agencyId = entry.agencyId + type = entry.type + color = entry.color + description = entry.description + longName = entry.longName + nullSafeShortName = entry.nullSafeShortName + shortName = entry.shortName + textColor = entry.textColor + url = entry.url + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun type(type: Long) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun longName(longName: String) = longName(JsonField.of(longName)) + + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun longName(longName: JsonField) = apply { this.longName = longName } + + fun nullSafeShortName(nullSafeShortName: String) = + nullSafeShortName(JsonField.of(nullSafeShortName)) + + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nullSafeShortName(nullSafeShortName: JsonField) = apply { + this.nullSafeShortName = nullSafeShortName + } + + fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shortName(shortName: JsonField) = apply { this.shortName = shortName } + + fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColor(textColor: JsonField) = apply { this.textColor = textColor } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RouteRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouteRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParams.kt new file mode 100644 index 0000000..f599b99 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParams.kt @@ -0,0 +1,190 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is RouteIdsForAgencyListParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RouteIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt new file mode 100644 index 0000000..f1077e5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt @@ -0,0 +1,566 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routeidsforagency + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class RouteIdsForAgencyListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RouteIdsForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouteIdsForAgencyListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routeIdsForAgencyListResponse: RouteIdsForAgencyListResponse) = apply { + code = routeIdsForAgencyListResponse.code + currentTime = routeIdsForAgencyListResponse.currentTime + text = routeIdsForAgencyListResponse.text + version = routeIdsForAgencyListResponse.version + data = routeIdsForAgencyListResponse.data + additionalProperties = routeIdsForAgencyListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RouteIdsForAgencyListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RouteIdsForAgencyListResponse = + RouteIdsForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RouteIdsForAgencyListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: String) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.size ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RouteIdsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouteIdsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParams.kt new file mode 100644 index 0000000..4f0bb91 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParams.kt @@ -0,0 +1,190 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is RoutesForAgencyListParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RoutesForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt new file mode 100644 index 0000000..ff092f7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt @@ -0,0 +1,1060 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforagency + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class RoutesForAgencyListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RoutesForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutesForAgencyListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routesForAgencyListResponse: RoutesForAgencyListResponse) = apply { + code = routesForAgencyListResponse.code + currentTime = routesForAgencyListResponse.currentTime + text = routesForAgencyListResponse.text + version = routesForAgencyListResponse.version + data = routesForAgencyListResponse.data + additionalProperties = routesForAgencyListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RoutesForAgencyListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RoutesForAgencyListResponse = + RoutesForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RoutesForAgencyListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Long = type.getRequired("type") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nullSafeShortName") + @ExcludeMissing + fun _nullSafeShortName(): JsonField = nullSafeShortName + + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName + + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var longName: JsonField = JsonMissing.of() + private var nullSafeShortName: JsonField = JsonMissing.of() + private var shortName: JsonField = JsonMissing.of() + private var textColor: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + agencyId = list.agencyId + type = list.type + color = list.color + description = list.description + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + url = list.url + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun type(type: Long) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun longName(longName: String) = longName(JsonField.of(longName)) + + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun longName(longName: JsonField) = apply { this.longName = longName } + + fun nullSafeShortName(nullSafeShortName: String) = + nullSafeShortName(JsonField.of(nullSafeShortName)) + + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nullSafeShortName(nullSafeShortName: JsonField) = apply { + this.nullSafeShortName = nullSafeShortName + } + + fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shortName(shortName: JsonField) = apply { this.shortName = shortName } + + fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColor(textColor: JsonField) = apply { this.textColor = textColor } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoutesForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutesForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParams.kt new file mode 100644 index 0000000..73bc6d9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParams.kt @@ -0,0 +1,278 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is RoutesForLocationListParams && lat == other.lat && lon == other.lon && latSpan == other.latSpan && lonSpan == other.lonSpan && query == other.query && radius == other.radius && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(lat, lon, latSpan, lonSpan, query, radius, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RoutesForLocationListParams{lat=$lat, lon=$lon, latSpan=$latSpan, lonSpan=$lonSpan, query=$query, radius=$radius, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt new file mode 100644 index 0000000..3aab1b2 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt @@ -0,0 +1,1098 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforlocation + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class RoutesForLocationListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RoutesForLocationListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutesForLocationListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routesForLocationListResponse: RoutesForLocationListResponse) = apply { + code = routesForLocationListResponse.code + currentTime = routesForLocationListResponse.currentTime + text = routesForLocationListResponse.text + version = routesForLocationListResponse.version + data = routesForLocationListResponse.data + additionalProperties = routesForLocationListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RoutesForLocationListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RoutesForLocationListResponse = + RoutesForLocationListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RoutesForLocationListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, outOfRange, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var outOfRange: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + outOfRange = data.outOfRange + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + /** + * Sets [Builder.outOfRange] to an arbitrary JSON value. + * + * You should usually call [Builder.outOfRange] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Long = type.getRequired("type") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nullSafeShortName") + @ExcludeMissing + fun _nullSafeShortName(): JsonField = nullSafeShortName + + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName + + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var longName: JsonField = JsonMissing.of() + private var nullSafeShortName: JsonField = JsonMissing.of() + private var shortName: JsonField = JsonMissing.of() + private var textColor: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + agencyId = list.agencyId + type = list.type + color = list.color + description = list.description + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + url = list.url + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun type(type: Long) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun longName(longName: String) = longName(JsonField.of(longName)) + + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun longName(longName: JsonField) = apply { this.longName = longName } + + fun nullSafeShortName(nullSafeShortName: String) = + nullSafeShortName(JsonField.of(nullSafeShortName)) + + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nullSafeShortName(nullSafeShortName: JsonField) = apply { + this.nullSafeShortName = nullSafeShortName + } + + fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shortName(shortName: JsonField) = apply { this.shortName = shortName } + + fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColor(textColor: JsonField) = apply { this.textColor = textColor } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoutesForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutesForLocationListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParams.kt new file mode 100644 index 0000000..510aa18 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParams.kt @@ -0,0 +1,217 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is ScheduleForRouteRetrieveParams && routeId == other.routeId && date == other.date && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(routeId, date, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ScheduleForRouteRetrieveParams{routeId=$routeId, date=$date, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt new file mode 100644 index 0000000..85a3f93 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt @@ -0,0 +1,3102 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforroute + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.ResponseWrapper + +class ScheduleForRouteRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleForRouteRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleForRouteRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scheduleForRouteRetrieveResponse: ScheduleForRouteRetrieveResponse) = + apply { + code = scheduleForRouteRetrieveResponse.code + currentTime = scheduleForRouteRetrieveResponse.currentTime + text = scheduleForRouteRetrieveResponse.text + version = scheduleForRouteRetrieveResponse.version + data = scheduleForRouteRetrieveResponse.data + additionalProperties = + scheduleForRouteRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScheduleForRouteRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScheduleForRouteRetrieveResponse = + ScheduleForRouteRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScheduleForRouteRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of() + ) : this(entry, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data(checkRequired("entry", entry), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (entry.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val routeId: JsonField, + private val scheduleDate: JsonField, + private val serviceIds: JsonField>, + private val stops: JsonField>, + private val stopTripGroupings: JsonField>, + private val trips: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDate") + @ExcludeMissing + scheduleDate: JsonField = JsonMissing.of(), + @JsonProperty("serviceIds") + @ExcludeMissing + serviceIds: JsonField> = JsonMissing.of(), + @JsonProperty("stops") + @ExcludeMissing + stops: JsonField> = JsonMissing.of(), + @JsonProperty("stopTripGroupings") + @ExcludeMissing + stopTripGroupings: JsonField> = JsonMissing.of(), + @JsonProperty("trips") + @ExcludeMissing + trips: JsonField> = JsonMissing.of(), + ) : this( + routeId, + scheduleDate, + serviceIds, + stops, + stopTripGroupings, + trips, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scheduleDate(): Long = scheduleDate.getRequired("scheduleDate") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun serviceIds(): List = serviceIds.getRequired("serviceIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun stops(): List = stops.getRequired("stops") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun stopTripGroupings(): List = + stopTripGroupings.getRequired("stopTripGroupings") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun trips(): List = trips.getRequired("trips") + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [scheduleDate]. + * + * Unlike [scheduleDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scheduleDate") + @ExcludeMissing + fun _scheduleDate(): JsonField = scheduleDate + + /** + * Returns the raw JSON value of [serviceIds]. + * + * Unlike [serviceIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceIds") + @ExcludeMissing + fun _serviceIds(): JsonField> = serviceIds + + /** + * Returns the raw JSON value of [stops]. + * + * Unlike [stops], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stops") @ExcludeMissing fun _stops(): JsonField> = stops + + /** + * Returns the raw JSON value of [stopTripGroupings]. + * + * Unlike [stopTripGroupings], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopTripGroupings") + @ExcludeMissing + fun _stopTripGroupings(): JsonField> = stopTripGroupings + + /** + * Returns the raw JSON value of [trips]. + * + * Unlike [trips], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .routeId() + * .scheduleDate() + * .serviceIds() + * .stops() + * .stopTripGroupings() + * .trips() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var routeId: JsonField? = null + private var scheduleDate: JsonField? = null + private var serviceIds: JsonField>? = null + private var stops: JsonField>? = null + private var stopTripGroupings: JsonField>? = null + private var trips: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + routeId = entry.routeId + scheduleDate = entry.scheduleDate + serviceIds = entry.serviceIds.map { it.toMutableList() } + stops = entry.stops.map { it.toMutableList() } + stopTripGroupings = entry.stopTripGroupings.map { it.toMutableList() } + trips = entry.trips.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun scheduleDate(scheduleDate: Long) = scheduleDate(JsonField.of(scheduleDate)) + + /** + * Sets [Builder.scheduleDate] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scheduleDate(scheduleDate: JsonField) = apply { + this.scheduleDate = scheduleDate + } + + fun serviceIds(serviceIds: List) = serviceIds(JsonField.of(serviceIds)) + + /** + * Sets [Builder.serviceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun serviceIds(serviceIds: JsonField>) = apply { + this.serviceIds = serviceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [serviceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addServiceId(serviceId: String) = apply { + serviceIds = + (serviceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("serviceIds", it).add(serviceId) + } + } + + fun stops(stops: List) = stops(JsonField.of(stops)) + + /** + * Sets [Builder.stops] to an arbitrary JSON value. + * + * You should usually call [Builder.stops] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun stops(stops: JsonField>) = apply { + this.stops = stops.map { it.toMutableList() } + } + + /** + * Adds a single [Stop] to [stops]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStop(stop: Stop) = apply { + stops = + (stops ?: JsonField.of(mutableListOf())).also { + checkKnown("stops", it).add(stop) + } + } + + fun stopTripGroupings(stopTripGroupings: List) = + stopTripGroupings(JsonField.of(stopTripGroupings)) + + /** + * Sets [Builder.stopTripGroupings] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTripGroupings] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTripGroupings(stopTripGroupings: JsonField>) = + apply { + this.stopTripGroupings = stopTripGroupings.map { it.toMutableList() } + } + + /** + * Adds a single [StopTripGrouping] to [stopTripGroupings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopTripGrouping(stopTripGrouping: StopTripGrouping) = apply { + stopTripGroupings = + (stopTripGroupings ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTripGroupings", it).add(stopTripGrouping) + } + } + + fun trips(trips: List) = trips(JsonField.of(trips)) + + /** + * Sets [Builder.trips] to an arbitrary JSON value. + * + * You should usually call [Builder.trips] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun trips(trips: JsonField>) = apply { + this.trips = trips.map { it.toMutableList() } + } + + /** + * Adds a single [Trip] to [trips]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrip(trip: Trip) = apply { + trips = + (trips ?: JsonField.of(mutableListOf())).also { + checkKnown("trips", it).add(trip) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .routeId() + * .scheduleDate() + * .serviceIds() + * .stops() + * .stopTripGroupings() + * .trips() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("routeId", routeId), + checkRequired("scheduleDate", scheduleDate), + checkRequired("serviceIds", serviceIds).map { it.toImmutable() }, + checkRequired("stops", stops).map { it.toImmutable() }, + checkRequired("stopTripGroupings", stopTripGroupings).map { + it.toImmutable() + }, + checkRequired("trips", trips).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + routeId() + scheduleDate() + serviceIds() + stops().forEach { it.validate() } + stopTripGroupings().forEach { it.validate() } + trips().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (scheduleDate.asKnown().isPresent) 1 else 0) + + (serviceIds.asKnown().getOrNull()?.size ?: 0) + + (stops.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stopTripGroupings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (trips.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Stop + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") + @ExcludeMissing + code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lat(): Double = lat.getRequired("lat") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun locationType(): Long = locationType.getRequired("locationType") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lon(): Double = lon.getRequired("lon") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun parent(): String = parent.getRequired("parent") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun routeIds(): List = routeIds.getRequired("routeIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun code(): Optional = code.getOptional("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun direction(): Optional = direction.getOptional("direction") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun wheelchairBoarding(): Optional = + wheelchairBoarding.getOptional("wheelchairBoarding") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [locationType]. + * + * Unlike [locationType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + + /** + * Returns the raw JSON value of [routeIds]. + * + * Unlike [routeIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds + + /** + * Returns the raw JSON value of [staticRouteIds]. + * + * Unlike [staticRouteIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [wheelchairBoarding]. + * + * Unlike [wheelchairBoarding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + fun _wheelchairBoarding(): JsonField = wheelchairBoarding + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Stop]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Stop]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var lat: JsonField? = null + private var locationType: JsonField? = null + private var lon: JsonField? = null + private var name: JsonField? = null + private var parent: JsonField? = null + private var routeIds: JsonField>? = null + private var staticRouteIds: JsonField>? = null + private var code: JsonField = JsonMissing.of() + private var direction: JsonField = JsonMissing.of() + private var wheelchairBoarding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stop: Stop) = apply { + id = stop.id + lat = stop.lat + locationType = stop.locationType + lon = stop.lon + name = stop.name + parent = stop.parent + routeIds = stop.routeIds.map { it.toMutableList() } + staticRouteIds = stop.staticRouteIds.map { it.toMutableList() } + code = stop.code + direction = stop.direction + wheelchairBoarding = stop.wheelchairBoarding + additionalProperties = stop.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + /** + * Sets [Builder.locationType] to an arbitrary JSON value. + * + * You should usually call [Builder.locationType] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun parent(parent: String) = parent(JsonField.of(parent)) + + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) + + /** + * Sets [Builder.routeIds] to an arbitrary JSON value. + * + * You should usually call [Builder.routeIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun routeIds(routeIds: JsonField>) = apply { + this.routeIds = routeIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [routeIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).also { + checkKnown("routeIds", it).add(routeId) + } + } + + fun staticRouteIds(staticRouteIds: List) = + staticRouteIds(JsonField.of(staticRouteIds)) + + /** + * Sets [Builder.staticRouteIds] to an arbitrary JSON value. + * + * You should usually call [Builder.staticRouteIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun staticRouteIds(staticRouteIds: JsonField>) = apply { + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [staticRouteIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).also { + checkKnown("staticRouteIds", it).add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun direction(direction: JsonField) = apply { + this.direction = direction + } + + fun wheelchairBoarding(wheelchairBoarding: String) = + wheelchairBoarding(JsonField.of(wheelchairBoarding)) + + /** + * Sets [Builder.wheelchairBoarding] to an arbitrary JSON value. + * + * You should usually call [Builder.wheelchairBoarding] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { + this.wheelchairBoarding = wheelchairBoarding + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Stop]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Stop = + Stop( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { + it.toImmutable() + }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Stop = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Stop && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Stop{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + class StopTripGrouping + private constructor( + private val directionId: JsonField, + private val stopIds: JsonField>, + private val tripHeadsigns: JsonField>, + private val tripIds: JsonField>, + private val tripsWithStopTimes: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("directionId") + @ExcludeMissing + directionId: JsonField = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + stopIds: JsonField> = JsonMissing.of(), + @JsonProperty("tripHeadsigns") + @ExcludeMissing + tripHeadsigns: JsonField> = JsonMissing.of(), + @JsonProperty("tripIds") + @ExcludeMissing + tripIds: JsonField> = JsonMissing.of(), + @JsonProperty("tripsWithStopTimes") + @ExcludeMissing + tripsWithStopTimes: JsonField> = JsonMissing.of(), + ) : this( + directionId, + stopIds, + tripHeadsigns, + tripIds, + tripsWithStopTimes, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun directionId(): String = directionId.getRequired("directionId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopIds(): List = stopIds.getRequired("stopIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tripHeadsigns(): List = tripHeadsigns.getRequired("tripHeadsigns") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tripIds(): List = tripIds.getRequired("tripIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tripsWithStopTimes(): Optional> = + tripsWithStopTimes.getOptional("tripsWithStopTimes") + + /** + * Returns the raw JSON value of [directionId]. + * + * Unlike [directionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("directionId") + @ExcludeMissing + fun _directionId(): JsonField = directionId + + /** + * Returns the raw JSON value of [stopIds]. + * + * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds + + /** + * Returns the raw JSON value of [tripHeadsigns]. + * + * Unlike [tripHeadsigns], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripHeadsigns") + @ExcludeMissing + fun _tripHeadsigns(): JsonField> = tripHeadsigns + + /** + * Returns the raw JSON value of [tripIds]. + * + * Unlike [tripIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripIds") + @ExcludeMissing + fun _tripIds(): JsonField> = tripIds + + /** + * Returns the raw JSON value of [tripsWithStopTimes]. + * + * Unlike [tripsWithStopTimes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripsWithStopTimes") + @ExcludeMissing + fun _tripsWithStopTimes(): JsonField> = tripsWithStopTimes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopTripGrouping]. + * + * The following fields are required: + * ```java + * .directionId() + * .stopIds() + * .tripHeadsigns() + * .tripIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTripGrouping]. */ + class Builder internal constructor() { + + private var directionId: JsonField? = null + private var stopIds: JsonField>? = null + private var tripHeadsigns: JsonField>? = null + private var tripIds: JsonField>? = null + private var tripsWithStopTimes: JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopTripGrouping: StopTripGrouping) = apply { + directionId = stopTripGrouping.directionId + stopIds = stopTripGrouping.stopIds.map { it.toMutableList() } + tripHeadsigns = stopTripGrouping.tripHeadsigns.map { it.toMutableList() } + tripIds = stopTripGrouping.tripIds.map { it.toMutableList() } + tripsWithStopTimes = + stopTripGrouping.tripsWithStopTimes.map { it.toMutableList() } + additionalProperties = stopTripGrouping.additionalProperties.toMutableMap() + } + + fun directionId(directionId: String) = directionId(JsonField.of(directionId)) + + /** + * Sets [Builder.directionId] to an arbitrary JSON value. + * + * You should usually call [Builder.directionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun directionId(directionId: JsonField) = apply { + this.directionId = directionId + } + + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + + /** + * Sets [Builder.stopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.stopIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [stopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) + } + } + + fun tripHeadsigns(tripHeadsigns: List) = + tripHeadsigns(JsonField.of(tripHeadsigns)) + + /** + * Sets [Builder.tripHeadsigns] to an arbitrary JSON value. + * + * You should usually call [Builder.tripHeadsigns] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tripHeadsigns(tripHeadsigns: JsonField>) = apply { + this.tripHeadsigns = tripHeadsigns.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tripHeadsigns]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTripHeadsign(tripHeadsign: String) = apply { + tripHeadsigns = + (tripHeadsigns ?: JsonField.of(mutableListOf())).also { + checkKnown("tripHeadsigns", it).add(tripHeadsign) + } + } + + fun tripIds(tripIds: List) = tripIds(JsonField.of(tripIds)) + + /** + * Sets [Builder.tripIds] to an arbitrary JSON value. + * + * You should usually call [Builder.tripIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripIds(tripIds: JsonField>) = apply { + this.tripIds = tripIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tripIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTripId(tripId: String) = apply { + tripIds = + (tripIds ?: JsonField.of(mutableListOf())).also { + checkKnown("tripIds", it).add(tripId) + } + } + + fun tripsWithStopTimes(tripsWithStopTimes: List) = + tripsWithStopTimes(JsonField.of(tripsWithStopTimes)) + + /** + * Sets [Builder.tripsWithStopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.tripsWithStopTimes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tripsWithStopTimes(tripsWithStopTimes: JsonField>) = + apply { + this.tripsWithStopTimes = tripsWithStopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [TripsWithStopTime] to [tripsWithStopTimes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTripsWithStopTime(tripsWithStopTime: TripsWithStopTime) = apply { + tripsWithStopTimes = + (tripsWithStopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("tripsWithStopTimes", it).add(tripsWithStopTime) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTripGrouping]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .directionId() + * .stopIds() + * .tripHeadsigns() + * .tripIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopTripGrouping = + StopTripGrouping( + checkRequired("directionId", directionId), + checkRequired("stopIds", stopIds).map { it.toImmutable() }, + checkRequired("tripHeadsigns", tripHeadsigns).map { it.toImmutable() }, + checkRequired("tripIds", tripIds).map { it.toImmutable() }, + (tripsWithStopTimes ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTripGrouping = apply { + if (validated) { + return@apply + } + + directionId() + stopIds() + tripHeadsigns() + tripIds() + tripsWithStopTimes().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (directionId.asKnown().isPresent) 1 else 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) + + (tripHeadsigns.asKnown().getOrNull()?.size ?: 0) + + (tripIds.asKnown().getOrNull()?.size ?: 0) + + (tripsWithStopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class TripsWithStopTime + private constructor( + private val stopTimes: JsonField>, + private val tripId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + ) : this(stopTimes, tripId, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun stopTimes(): List = stopTimes.getRequired("stopTimes") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * Returns the raw JSON value of [stopTimes]. + * + * Unlike [stopTimes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TripsWithStopTime]. + * + * The following fields are required: + * ```java + * .stopTimes() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripsWithStopTime]. */ + class Builder internal constructor() { + + private var stopTimes: JsonField>? = null + private var tripId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tripsWithStopTime: TripsWithStopTime) = apply { + stopTimes = tripsWithStopTime.stopTimes.map { it.toMutableList() } + tripId = tripsWithStopTime.tripId + additionalProperties = + tripsWithStopTime.additionalProperties.toMutableMap() + } + + fun stopTimes(stopTimes: List) = + stopTimes(JsonField.of(stopTimes)) + + /** + * Sets [Builder.stopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTimes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTimes(stopTimes: JsonField>) = apply { + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [StopTime] to [stopTimes]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTimes", it).add(stopTime) + } + } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripsWithStopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .stopTimes() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripsWithStopTime = + TripsWithStopTime( + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("tripId", tripId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripsWithStopTime = apply { + if (validated) { + return@apply + } + + stopTimes().forEach { it.validate() } + tripId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalEnabled: JsonField, + private val arrivalTime: JsonField, + private val departureEnabled: JsonField, + private val departureTime: JsonField, + private val stopId: JsonField, + private val tripId: JsonField, + private val serviceId: JsonField, + private val stopHeadsign: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalEnabled") + @ExcludeMissing + arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + arrivalTime, + departureEnabled, + departureTime, + stopId, + tripId, + serviceId, + stopHeadsign, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun departureEnabled(): Boolean = + departureEnabled.getRequired("departureEnabled") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun departureTime(): Long = departureTime.getRequired("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun serviceId(): Optional = serviceId.getOptional("serviceId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun stopHeadsign(): Optional = + stopHeadsign.getOptional("stopHeadsign") + + /** + * Returns the raw JSON value of [arrivalEnabled]. + * + * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled + + /** + * Returns the raw JSON value of [arrivalTime]. + * + * Unlike [arrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime + + /** + * Returns the raw JSON value of [departureEnabled]. + * + * Unlike [departureEnabled], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("departureEnabled") + @ExcludeMissing + fun _departureEnabled(): JsonField = departureEnabled + + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [serviceId]. + * + * Unlike [serviceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId + + /** + * Returns the raw JSON value of [stopHeadsign]. + * + * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopTime]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .stopId() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalEnabled: JsonField? = null + private var arrivalTime: JsonField? = null + private var departureEnabled: JsonField? = null + private var departureTime: JsonField? = null + private var stopId: JsonField? = null + private var tripId: JsonField? = null + private var serviceId: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalEnabled = stopTime.arrivalEnabled + arrivalTime = stopTime.arrivalTime + departureEnabled = stopTime.departureEnabled + departureTime = stopTime.departureTime + stopId = stopTime.stopId + tripId = stopTime.tripId + serviceId = stopTime.serviceId + stopHeadsign = stopTime.stopHeadsign + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) + + /** + * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun arrivalEnabled(arrivalEnabled: JsonField) = apply { + this.arrivalEnabled = arrivalEnabled + } + + fun arrivalTime(arrivalTime: Long) = + arrivalTime(JsonField.of(arrivalTime)) + + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } + + fun departureEnabled(departureEnabled: Boolean) = + departureEnabled(JsonField.of(departureEnabled)) + + /** + * Sets [Builder.departureEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.departureEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun departureEnabled(departureEnabled: JsonField) = apply { + this.departureEnabled = departureEnabled + } + + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) + + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + /** + * Sets [Builder.serviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun serviceId(serviceId: JsonField) = apply { + this.serviceId = serviceId + } + + fun stopHeadsign(stopHeadsign: String) = + stopHeadsign(JsonField.of(stopHeadsign)) + + /** + * Sets [Builder.stopHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.stopHeadsign] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopHeadsign(stopHeadsign: JsonField) = apply { + this.stopHeadsign = stopHeadsign + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .stopId() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopTime = + StopTime( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureEnabled", departureEnabled), + checkRequired("departureTime", departureTime), + checkRequired("stopId", stopId), + checkRequired("tripId", tripId), + serviceId, + stopHeadsign, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalEnabled() + arrivalTime() + departureEnabled() + departureTime() + stopId() + tripId() + serviceId() + stopHeadsign() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureEnabled.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && stopId == other.stopId && tripId == other.tripId && serviceId == other.serviceId && stopHeadsign == other.stopHeadsign && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, stopId, tripId, serviceId, stopHeadsign, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, stopId=$stopId, tripId=$tripId, serviceId=$serviceId, stopHeadsign=$stopHeadsign, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripsWithStopTime && stopTimes == other.stopTimes && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(stopTimes, tripId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripsWithStopTime{stopTimes=$stopTimes, tripId=$tripId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTripGrouping && directionId == other.directionId && stopIds == other.stopIds && tripHeadsigns == other.tripHeadsigns && tripIds == other.tripIds && tripsWithStopTimes == other.tripsWithStopTimes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(directionId, stopIds, tripHeadsigns, tripIds, tripsWithStopTimes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" + } + + class Trip + private constructor( + private val id: JsonField, + private val routeId: JsonField, + private val serviceId: JsonField, + private val blockId: JsonField, + private val directionId: JsonField, + private val peakOffpeak: JsonField, + private val routeShortName: JsonField, + private val shapeId: JsonField, + private val timeZone: JsonField, + private val tripHeadsign: JsonField, + private val tripShortName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("blockId") + @ExcludeMissing + blockId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + directionId: JsonField = JsonMissing.of(), + @JsonProperty("peakOffpeak") + @ExcludeMissing + peakOffpeak: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shapeId") + @ExcludeMissing + shapeId: JsonField = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripShortName") + @ExcludeMissing + tripShortName: JsonField = JsonMissing.of(), + ) : this( + id, + routeId, + serviceId, + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceId(): String = serviceId.getRequired("serviceId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun blockId(): Optional = blockId.getOptional("blockId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun directionId(): Optional = directionId.getOptional("directionId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun peakOffpeak(): Optional = peakOffpeak.getOptional("peakOffpeak") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun routeShortName(): Optional = + routeShortName.getOptional("routeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun shapeId(): Optional = shapeId.getOptional("shapeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun timeZone(): Optional = timeZone.getOptional("timeZone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tripHeadsign(): Optional = tripHeadsign.getOptional("tripHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tripShortName(): Optional = tripShortName.getOptional("tripShortName") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [serviceId]. + * + * Unlike [serviceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId + + /** + * Returns the raw JSON value of [blockId]. + * + * Unlike [blockId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("blockId") @ExcludeMissing fun _blockId(): JsonField = blockId + + /** + * Returns the raw JSON value of [directionId]. + * + * Unlike [directionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("directionId") + @ExcludeMissing + fun _directionId(): JsonField = directionId + + /** + * Returns the raw JSON value of [peakOffpeak]. + * + * Unlike [peakOffpeak], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("peakOffpeak") + @ExcludeMissing + fun _peakOffpeak(): JsonField = peakOffpeak + + /** + * Returns the raw JSON value of [routeShortName]. + * + * Unlike [routeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName + + /** + * Returns the raw JSON value of [shapeId]. + * + * Unlike [shapeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId + + /** + * Returns the raw JSON value of [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * Returns the raw JSON value of [tripHeadsign]. + * + * Unlike [tripHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign + + /** + * Returns the raw JSON value of [tripShortName]. + * + * Unlike [tripShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripShortName") + @ExcludeMissing + fun _tripShortName(): JsonField = tripShortName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Trip]. + * + * The following fields are required: + * ```java + * .id() + * .routeId() + * .serviceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Trip]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var routeId: JsonField? = null + private var serviceId: JsonField? = null + private var blockId: JsonField = JsonMissing.of() + private var directionId: JsonField = JsonMissing.of() + private var peakOffpeak: JsonField = JsonMissing.of() + private var routeShortName: JsonField = JsonMissing.of() + private var shapeId: JsonField = JsonMissing.of() + private var timeZone: JsonField = JsonMissing.of() + private var tripHeadsign: JsonField = JsonMissing.of() + private var tripShortName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trip: Trip) = apply { + id = trip.id + routeId = trip.routeId + serviceId = trip.serviceId + blockId = trip.blockId + directionId = trip.directionId + peakOffpeak = trip.peakOffpeak + routeShortName = trip.routeShortName + shapeId = trip.shapeId + timeZone = trip.timeZone + tripHeadsign = trip.tripHeadsign + tripShortName = trip.tripShortName + additionalProperties = trip.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + /** + * Sets [Builder.serviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceId(serviceId: JsonField) = apply { + this.serviceId = serviceId + } + + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) + + /** + * Sets [Builder.blockId] to an arbitrary JSON value. + * + * You should usually call [Builder.blockId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + fun directionId(directionId: String) = directionId(JsonField.of(directionId)) + + /** + * Sets [Builder.directionId] to an arbitrary JSON value. + * + * You should usually call [Builder.directionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun directionId(directionId: JsonField) = apply { + this.directionId = directionId + } + + fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) + + /** + * Sets [Builder.peakOffpeak] to an arbitrary JSON value. + * + * You should usually call [Builder.peakOffpeak] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun peakOffpeak(peakOffpeak: JsonField) = apply { + this.peakOffpeak = peakOffpeak + } + + fun routeShortName(routeShortName: String) = + routeShortName(JsonField.of(routeShortName)) + + /** + * Sets [Builder.routeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun routeShortName(routeShortName: JsonField) = apply { + this.routeShortName = routeShortName + } + + fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) + + /** + * Sets [Builder.shapeId] to an arbitrary JSON value. + * + * You should usually call [Builder.shapeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } + + fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * Sets [Builder.timeZone] to an arbitrary JSON value. + * + * You should usually call [Builder.timeZone] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + + fun tripHeadsign(tripHeadsign: String) = + tripHeadsign(JsonField.of(tripHeadsign)) + + /** + * Sets [Builder.tripHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.tripHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripHeadsign(tripHeadsign: JsonField) = apply { + this.tripHeadsign = tripHeadsign + } + + fun tripShortName(tripShortName: String) = + tripShortName(JsonField.of(tripShortName)) + + /** + * Sets [Builder.tripShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.tripShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripShortName(tripShortName: JsonField) = apply { + this.tripShortName = tripShortName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Trip]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .routeId() + * .serviceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Trip = + Trip( + checkRequired("id", id), + checkRequired("routeId", routeId), + checkRequired("serviceId", serviceId), + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Trip = apply { + if (validated) { + return@apply + } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (if (directionId.asKnown().isPresent) 1 else 0) + + (if (peakOffpeak.asKnown().isPresent) 1 else 0) + + (if (routeShortName.asKnown().isPresent) 1 else 0) + + (if (shapeId.asKnown().isPresent) 1 else 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (if (tripShortName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Trip && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Trip{id=$id, routeId=$routeId, serviceId=$serviceId, blockId=$blockId, directionId=$directionId, peakOffpeak=$peakOffpeak, routeShortName=$routeShortName, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && routeId == other.routeId && scheduleDate == other.scheduleDate && serviceIds == other.serviceIds && stops == other.stops && stopTripGroupings == other.stopTripGroupings && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(routeId, scheduleDate, serviceIds, stops, stopTripGroupings, trips, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stops=$stops, stopTripGroupings=$stopTripGroupings, trips=$trips, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{entry=$entry, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleForRouteRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleForRouteRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParams.kt new file mode 100644 index 0000000..9500f26 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParams.kt @@ -0,0 +1,217 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is ScheduleForStopRetrieveParams && stopId == other.stopId && date == other.date && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, date, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ScheduleForStopRetrieveParams{stopId=$stopId, date=$date, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt new file mode 100644 index 0000000..d9e6767 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt @@ -0,0 +1,2122 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforstop + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class ScheduleForStopRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleForStopRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleForStopRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scheduleForStopRetrieveResponse: ScheduleForStopRetrieveResponse) = + apply { + code = scheduleForStopRetrieveResponse.code + currentTime = scheduleForStopRetrieveResponse.currentTime + text = scheduleForStopRetrieveResponse.text + version = scheduleForStopRetrieveResponse.version + data = scheduleForStopRetrieveResponse.data + additionalProperties = + scheduleForStopRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScheduleForStopRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScheduleForStopRetrieveResponse = + ScheduleForStopRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScheduleForStopRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val date: JsonField, + private val stopId: JsonField, + private val stopRouteSchedules: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopRouteSchedules") + @ExcludeMissing + stopRouteSchedules: JsonField> = JsonMissing.of(), + ) : this(date, stopId, stopRouteSchedules, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun date(): Long = date.getRequired("date") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun stopRouteSchedules(): List = + stopRouteSchedules.getRequired("stopRouteSchedules") + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId + + /** + * Returns the raw JSON value of [stopRouteSchedules]. + * + * Unlike [stopRouteSchedules], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopRouteSchedules") + @ExcludeMissing + fun _stopRouteSchedules(): JsonField> = stopRouteSchedules + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .date() + * .stopId() + * .stopRouteSchedules() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var date: JsonField? = null + private var stopId: JsonField? = null + private var stopRouteSchedules: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + date = entry.date + stopId = entry.stopId + stopRouteSchedules = entry.stopRouteSchedules.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun date(date: Long) = date(JsonField.of(date)) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun date(date: JsonField) = apply { this.date = date } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun stopRouteSchedules(stopRouteSchedules: List) = + stopRouteSchedules(JsonField.of(stopRouteSchedules)) + + /** + * Sets [Builder.stopRouteSchedules] to an arbitrary JSON value. + * + * You should usually call [Builder.stopRouteSchedules] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopRouteSchedules(stopRouteSchedules: JsonField>) = + apply { + this.stopRouteSchedules = stopRouteSchedules.map { it.toMutableList() } + } + + /** + * Adds a single [StopRouteSchedule] to [stopRouteSchedules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopRouteSchedule(stopRouteSchedule: StopRouteSchedule) = apply { + stopRouteSchedules = + (stopRouteSchedules ?: JsonField.of(mutableListOf())).also { + checkKnown("stopRouteSchedules", it).add(stopRouteSchedule) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .date() + * .stopId() + * .stopRouteSchedules() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("date", date), + checkRequired("stopId", stopId), + checkRequired("stopRouteSchedules", stopRouteSchedules).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + date() + stopId() + stopRouteSchedules().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (date.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (stopRouteSchedules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class StopRouteSchedule + private constructor( + private val routeId: JsonField, + private val stopRouteDirectionSchedules: + JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopRouteDirectionSchedules") + @ExcludeMissing + stopRouteDirectionSchedules: JsonField> = + JsonMissing.of(), + ) : this(routeId, stopRouteDirectionSchedules, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopRouteDirectionSchedules(): List = + stopRouteDirectionSchedules.getRequired("stopRouteDirectionSchedules") + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [stopRouteDirectionSchedules]. + * + * Unlike [stopRouteDirectionSchedules], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("stopRouteDirectionSchedules") + @ExcludeMissing + fun _stopRouteDirectionSchedules(): JsonField> = + stopRouteDirectionSchedules + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [StopRouteSchedule]. + * + * The following fields are required: + * ```java + * .routeId() + * .stopRouteDirectionSchedules() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopRouteSchedule]. */ + class Builder internal constructor() { + + private var routeId: JsonField? = null + private var stopRouteDirectionSchedules: + JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopRouteSchedule: StopRouteSchedule) = apply { + routeId = stopRouteSchedule.routeId + stopRouteDirectionSchedules = + stopRouteSchedule.stopRouteDirectionSchedules.map { it.toMutableList() } + additionalProperties = stopRouteSchedule.additionalProperties.toMutableMap() + } + + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun stopRouteDirectionSchedules( + stopRouteDirectionSchedules: List + ) = stopRouteDirectionSchedules(JsonField.of(stopRouteDirectionSchedules)) + + /** + * Sets [Builder.stopRouteDirectionSchedules] to an arbitrary JSON value. + * + * You should usually call [Builder.stopRouteDirectionSchedules] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun stopRouteDirectionSchedules( + stopRouteDirectionSchedules: JsonField> + ) = apply { + this.stopRouteDirectionSchedules = + stopRouteDirectionSchedules.map { it.toMutableList() } + } + + /** + * Adds a single [StopRouteDirectionSchedule] to [stopRouteDirectionSchedules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopRouteDirectionSchedule( + stopRouteDirectionSchedule: StopRouteDirectionSchedule + ) = apply { + stopRouteDirectionSchedules = + (stopRouteDirectionSchedules ?: JsonField.of(mutableListOf())).also { + checkKnown("stopRouteDirectionSchedules", it) + .add(stopRouteDirectionSchedule) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopRouteSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .routeId() + * .stopRouteDirectionSchedules() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopRouteSchedule = + StopRouteSchedule( + checkRequired("routeId", routeId), + checkRequired( + "stopRouteDirectionSchedules", + stopRouteDirectionSchedules, + ) + .map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopRouteSchedule = apply { + if (validated) { + return@apply + } + + routeId() + stopRouteDirectionSchedules().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (routeId.asKnown().isPresent) 1 else 0) + + (stopRouteDirectionSchedules.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class StopRouteDirectionSchedule + private constructor( + private val scheduleStopTimes: JsonField>, + private val tripHeadsign: JsonField, + private val scheduleFrequencies: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scheduleStopTimes") + @ExcludeMissing + scheduleStopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("scheduleFrequencies") + @ExcludeMissing + scheduleFrequencies: JsonField> = JsonMissing.of(), + ) : this(scheduleStopTimes, tripHeadsign, scheduleFrequencies, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scheduleStopTimes(): List = + scheduleStopTimes.getRequired("scheduleStopTimes") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduleFrequencies(): Optional> = + scheduleFrequencies.getOptional("scheduleFrequencies") + + /** + * Returns the raw JSON value of [scheduleStopTimes]. + * + * Unlike [scheduleStopTimes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduleStopTimes") + @ExcludeMissing + fun _scheduleStopTimes(): JsonField> = scheduleStopTimes + + /** + * Returns the raw JSON value of [tripHeadsign]. + * + * Unlike [tripHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign + + /** + * Returns the raw JSON value of [scheduleFrequencies]. + * + * Unlike [scheduleFrequencies], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduleFrequencies") + @ExcludeMissing + fun _scheduleFrequencies(): JsonField> = + scheduleFrequencies + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [StopRouteDirectionSchedule]. + * + * The following fields are required: + * ```java + * .scheduleStopTimes() + * .tripHeadsign() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopRouteDirectionSchedule]. */ + class Builder internal constructor() { + + private var scheduleStopTimes: JsonField>? = + null + private var tripHeadsign: JsonField? = null + private var scheduleFrequencies: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopRouteDirectionSchedule: StopRouteDirectionSchedule) = + apply { + scheduleStopTimes = + stopRouteDirectionSchedule.scheduleStopTimes.map { + it.toMutableList() + } + tripHeadsign = stopRouteDirectionSchedule.tripHeadsign + scheduleFrequencies = + stopRouteDirectionSchedule.scheduleFrequencies.map { + it.toMutableList() + } + additionalProperties = + stopRouteDirectionSchedule.additionalProperties.toMutableMap() + } + + fun scheduleStopTimes(scheduleStopTimes: List) = + scheduleStopTimes(JsonField.of(scheduleStopTimes)) + + /** + * Sets [Builder.scheduleStopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleStopTimes] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun scheduleStopTimes( + scheduleStopTimes: JsonField> + ) = apply { + this.scheduleStopTimes = scheduleStopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [ScheduleStopTime] to [scheduleStopTimes]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScheduleStopTime(scheduleStopTime: ScheduleStopTime) = apply { + scheduleStopTimes = + (scheduleStopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("scheduleStopTimes", it).add(scheduleStopTime) + } + } + + fun tripHeadsign(tripHeadsign: String) = + tripHeadsign(JsonField.of(tripHeadsign)) + + /** + * Sets [Builder.tripHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.tripHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripHeadsign(tripHeadsign: JsonField) = apply { + this.tripHeadsign = tripHeadsign + } + + fun scheduleFrequencies(scheduleFrequencies: List) = + scheduleFrequencies(JsonField.of(scheduleFrequencies)) + + /** + * Sets [Builder.scheduleFrequencies] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleFrequencies] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun scheduleFrequencies( + scheduleFrequencies: JsonField> + ) = apply { + this.scheduleFrequencies = + scheduleFrequencies.map { it.toMutableList() } + } + + /** + * Adds a single [ScheduleFrequency] to [scheduleFrequencies]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScheduleFrequency(scheduleFrequency: ScheduleFrequency) = apply { + scheduleFrequencies = + (scheduleFrequencies ?: JsonField.of(mutableListOf())).also { + checkKnown("scheduleFrequencies", it).add(scheduleFrequency) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopRouteDirectionSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .scheduleStopTimes() + * .tripHeadsign() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopRouteDirectionSchedule = + StopRouteDirectionSchedule( + checkRequired("scheduleStopTimes", scheduleStopTimes).map { + it.toImmutable() + }, + checkRequired("tripHeadsign", tripHeadsign), + (scheduleFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopRouteDirectionSchedule = apply { + if (validated) { + return@apply + } + + scheduleStopTimes().forEach { it.validate() } + tripHeadsign() + scheduleFrequencies().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (scheduleStopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (scheduleFrequencies.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class ScheduleStopTime + private constructor( + private val arrivalEnabled: JsonField, + private val arrivalTime: JsonField, + private val departureEnabled: JsonField, + private val departureTime: JsonField, + private val serviceId: JsonField, + private val tripId: JsonField, + private val stopHeadsign: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalEnabled") + @ExcludeMissing + arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + arrivalTime, + departureEnabled, + departureTime, + serviceId, + tripId, + stopHeadsign, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun departureEnabled(): Boolean = + departureEnabled.getRequired("departureEnabled") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun departureTime(): Long = departureTime.getRequired("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun serviceId(): String = serviceId.getRequired("serviceId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun stopHeadsign(): Optional = + stopHeadsign.getOptional("stopHeadsign") + + /** + * Returns the raw JSON value of [arrivalEnabled]. + * + * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled + + /** + * Returns the raw JSON value of [arrivalTime]. + * + * Unlike [arrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime + + /** + * Returns the raw JSON value of [departureEnabled]. + * + * Unlike [departureEnabled], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("departureEnabled") + @ExcludeMissing + fun _departureEnabled(): JsonField = departureEnabled + + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime + + /** + * Returns the raw JSON value of [serviceId]. + * + * Unlike [serviceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [stopHeadsign]. + * + * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleStopTime]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .serviceId() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleStopTime]. */ + class Builder internal constructor() { + + private var arrivalEnabled: JsonField? = null + private var arrivalTime: JsonField? = null + private var departureEnabled: JsonField? = null + private var departureTime: JsonField? = null + private var serviceId: JsonField? = null + private var tripId: JsonField? = null + private var stopHeadsign: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scheduleStopTime: ScheduleStopTime) = apply { + arrivalEnabled = scheduleStopTime.arrivalEnabled + arrivalTime = scheduleStopTime.arrivalTime + departureEnabled = scheduleStopTime.departureEnabled + departureTime = scheduleStopTime.departureTime + serviceId = scheduleStopTime.serviceId + tripId = scheduleStopTime.tripId + stopHeadsign = scheduleStopTime.stopHeadsign + additionalProperties = + scheduleStopTime.additionalProperties.toMutableMap() + } + + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) + + /** + * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun arrivalEnabled(arrivalEnabled: JsonField) = apply { + this.arrivalEnabled = arrivalEnabled + } + + fun arrivalTime(arrivalTime: Long) = + arrivalTime(JsonField.of(arrivalTime)) + + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } + + fun departureEnabled(departureEnabled: Boolean) = + departureEnabled(JsonField.of(departureEnabled)) + + /** + * Sets [Builder.departureEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.departureEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun departureEnabled(departureEnabled: JsonField) = apply { + this.departureEnabled = departureEnabled + } + + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) + + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + /** + * Sets [Builder.serviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun serviceId(serviceId: JsonField) = apply { + this.serviceId = serviceId + } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun stopHeadsign(stopHeadsign: String) = + stopHeadsign(JsonField.of(stopHeadsign)) + + /** + * Sets [Builder.stopHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.stopHeadsign] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopHeadsign(stopHeadsign: JsonField) = apply { + this.stopHeadsign = stopHeadsign + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScheduleStopTime]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .serviceId() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScheduleStopTime = + ScheduleStopTime( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureEnabled", departureEnabled), + checkRequired("departureTime", departureTime), + checkRequired("serviceId", serviceId), + checkRequired("tripId", tripId), + stopHeadsign, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScheduleStopTime = apply { + if (validated) { + return@apply + } + + arrivalEnabled() + arrivalTime() + departureEnabled() + departureTime() + serviceId() + tripId() + stopHeadsign() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureEnabled.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleStopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && serviceId == other.serviceId && tripId == other.tripId && stopHeadsign == other.stopHeadsign && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, tripId, stopHeadsign, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleStopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, tripId=$tripId, stopHeadsign=$stopHeadsign, additionalProperties=$additionalProperties}" + } + + class ScheduleFrequency + private constructor( + private val endTime: JsonField, + private val headway: JsonField, + private val serviceDate: JsonField, + private val serviceId: JsonField, + private val startTime: JsonField, + private val tripId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("endTime") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("headway") + @ExcludeMissing + headway: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("startTime") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + ) : this( + endTime, + headway, + serviceDate, + serviceId, + startTime, + tripId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun endTime(): Long = endTime.getRequired("endTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun headway(): Int = headway.getRequired("headway") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun serviceId(): String = serviceId.getRequired("serviceId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun startTime(): Long = startTime.getRequired("startTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("endTime") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [headway]. + * + * Unlike [headway], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("headway") + @ExcludeMissing + fun _headway(): JsonField = headway + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [serviceId]. + * + * Unlike [serviceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("startTime") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleFrequency]. + * + * The following fields are required: + * ```java + * .endTime() + * .headway() + * .serviceDate() + * .serviceId() + * .startTime() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleFrequency]. */ + class Builder internal constructor() { + + private var endTime: JsonField? = null + private var headway: JsonField? = null + private var serviceDate: JsonField? = null + private var serviceId: JsonField? = null + private var startTime: JsonField? = null + private var tripId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scheduleFrequency: ScheduleFrequency) = apply { + endTime = scheduleFrequency.endTime + headway = scheduleFrequency.headway + serviceDate = scheduleFrequency.serviceDate + serviceId = scheduleFrequency.serviceId + startTime = scheduleFrequency.startTime + tripId = scheduleFrequency.tripId + additionalProperties = + scheduleFrequency.additionalProperties.toMutableMap() + } + + fun endTime(endTime: Long) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun headway(headway: Int) = headway(JsonField.of(headway)) + + /** + * Sets [Builder.headway] to an arbitrary JSON value. + * + * You should usually call [Builder.headway] with a well-typed [Int] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun headway(headway: JsonField) = apply { this.headway = headway } + + fun serviceDate(serviceDate: Long) = + serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + /** + * Sets [Builder.serviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun serviceId(serviceId: JsonField) = apply { + this.serviceId = serviceId + } + + fun startTime(startTime: Long) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScheduleFrequency]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .endTime() + * .headway() + * .serviceDate() + * .serviceId() + * .startTime() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScheduleFrequency = + ScheduleFrequency( + checkRequired("endTime", endTime), + checkRequired("headway", headway), + checkRequired("serviceDate", serviceDate), + checkRequired("serviceId", serviceId), + checkRequired("startTime", startTime), + checkRequired("tripId", tripId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScheduleFrequency = apply { + if (validated) { + return@apply + } + + endTime() + headway() + serviceDate() + serviceId() + startTime() + tripId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (headway.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleFrequency && endTime == other.endTime && headway == other.headway && serviceDate == other.serviceDate && serviceId == other.serviceId && startTime == other.startTime && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endTime, headway, serviceDate, serviceId, startTime, tripId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleFrequency{endTime=$endTime, headway=$headway, serviceDate=$serviceDate, serviceId=$serviceId, startTime=$startTime, tripId=$tripId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopRouteDirectionSchedule && scheduleStopTimes == other.scheduleStopTimes && tripHeadsign == other.tripHeadsign && scheduleFrequencies == other.scheduleFrequencies && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(scheduleStopTimes, tripHeadsign, scheduleFrequencies, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopRouteDirectionSchedule{scheduleStopTimes=$scheduleStopTimes, tripHeadsign=$tripHeadsign, scheduleFrequencies=$scheduleFrequencies, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopRouteSchedule && routeId == other.routeId && stopRouteDirectionSchedules == other.stopRouteDirectionSchedules && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(routeId, stopRouteDirectionSchedules, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopRouteSchedule{routeId=$routeId, stopRouteDirectionSchedules=$stopRouteDirectionSchedules, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && date == other.date && stopId == other.stopId && stopRouteSchedules == other.stopRouteSchedules && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(date, stopId, stopRouteSchedules, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{date=$date, stopId=$stopId, stopRouteSchedules=$stopRouteSchedules, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleForStopRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleForStopRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParams.kt new file mode 100644 index 0000000..20bceac --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParams.kt @@ -0,0 +1,221 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is SearchForRouteListParams && input == other.input && maxCount == other.maxCount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "SearchForRouteListParams{input=$input, maxCount=$maxCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt new file mode 100644 index 0000000..36fe683 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt @@ -0,0 +1,1095 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforroute + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class SearchForRouteListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SearchForRouteListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SearchForRouteListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(searchForRouteListResponse: SearchForRouteListResponse) = apply { + code = searchForRouteListResponse.code + currentTime = searchForRouteListResponse.currentTime + text = searchForRouteListResponse.text + version = searchForRouteListResponse.version + data = searchForRouteListResponse.data + additionalProperties = searchForRouteListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SearchForRouteListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SearchForRouteListResponse = + SearchForRouteListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + data, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SearchForRouteListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, outOfRange, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var outOfRange: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + outOfRange = data.outOfRange + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + /** + * Sets [Builder.outOfRange] to an arbitrary JSON value. + * + * You should usually call [Builder.outOfRange] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Long = type.getRequired("type") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nullSafeShortName") + @ExcludeMissing + fun _nullSafeShortName(): JsonField = nullSafeShortName + + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName + + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var longName: JsonField = JsonMissing.of() + private var nullSafeShortName: JsonField = JsonMissing.of() + private var shortName: JsonField = JsonMissing.of() + private var textColor: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + agencyId = list.agencyId + type = list.type + color = list.color + description = list.description + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + url = list.url + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun type(type: Long) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun longName(longName: String) = longName(JsonField.of(longName)) + + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun longName(longName: JsonField) = apply { this.longName = longName } + + fun nullSafeShortName(nullSafeShortName: String) = + nullSafeShortName(JsonField.of(nullSafeShortName)) + + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nullSafeShortName(nullSafeShortName: JsonField) = apply { + this.nullSafeShortName = nullSafeShortName + } + + fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shortName(shortName: JsonField) = apply { this.shortName = shortName } + + fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColor(textColor: JsonField) = apply { this.textColor = textColor } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SearchForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SearchForRouteListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParams.kt new file mode 100644 index 0000000..8c3093a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParams.kt @@ -0,0 +1,221 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is SearchForStopListParams && input == other.input && maxCount == other.maxCount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "SearchForStopListParams{input=$input, maxCount=$maxCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt new file mode 100644 index 0000000..946d49e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt @@ -0,0 +1,1175 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforstop + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class SearchForStopListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SearchForStopListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SearchForStopListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(searchForStopListResponse: SearchForStopListResponse) = apply { + code = searchForStopListResponse.code + currentTime = searchForStopListResponse.currentTime + text = searchForStopListResponse.text + version = searchForStopListResponse.version + data = searchForStopListResponse.data + additionalProperties = searchForStopListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SearchForStopListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SearchForStopListResponse = + SearchForStopListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + data, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SearchForStopListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, outOfRange, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var outOfRange: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + outOfRange = data.outOfRange + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + /** + * Sets [Builder.outOfRange] to an arbitrary JSON value. + * + * You should usually call [Builder.outOfRange] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Double = lat.getRequired("lat") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun locationType(): Long = locationType.getRequired("locationType") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Double = lon.getRequired("lon") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun parent(): String = parent.getRequired("parent") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun staticRouteIds(): kotlin.collections.List = + staticRouteIds.getRequired("staticRouteIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun code(): Optional = code.getOptional("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun direction(): Optional = direction.getOptional("direction") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun wheelchairBoarding(): Optional = + wheelchairBoarding.getOptional("wheelchairBoarding") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [locationType]. + * + * Unlike [locationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + + /** + * Returns the raw JSON value of [routeIds]. + * + * Unlike [routeIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds + + /** + * Returns the raw JSON value of [staticRouteIds]. + * + * Unlike [staticRouteIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [wheelchairBoarding]. + * + * Unlike [wheelchairBoarding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + fun _wheelchairBoarding(): JsonField = wheelchairBoarding + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var lat: JsonField? = null + private var locationType: JsonField? = null + private var lon: JsonField? = null + private var name: JsonField? = null + private var parent: JsonField? = null + private var routeIds: JsonField>? = null + private var staticRouteIds: JsonField>? = null + private var code: JsonField = JsonMissing.of() + private var direction: JsonField = JsonMissing.of() + private var wheelchairBoarding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + lat = list.lat + locationType = list.locationType + lon = list.lon + name = list.name + parent = list.parent + routeIds = list.routeIds.map { it.toMutableList() } + staticRouteIds = list.staticRouteIds.map { it.toMutableList() } + code = list.code + direction = list.direction + wheelchairBoarding = list.wheelchairBoarding + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + /** + * Sets [Builder.locationType] to an arbitrary JSON value. + * + * You should usually call [Builder.locationType] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun parent(parent: String) = parent(JsonField.of(parent)) + + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + fun routeIds(routeIds: kotlin.collections.List) = + routeIds(JsonField.of(routeIds)) + + /** + * Sets [Builder.routeIds] to an arbitrary JSON value. + * + * You should usually call [Builder.routeIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeIds(routeIds: JsonField>) = apply { + this.routeIds = routeIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [routeIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).also { + checkKnown("routeIds", it).add(routeId) + } + } + + fun staticRouteIds(staticRouteIds: kotlin.collections.List) = + staticRouteIds(JsonField.of(staticRouteIds)) + + /** + * Sets [Builder.staticRouteIds] to an arbitrary JSON value. + * + * You should usually call [Builder.staticRouteIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun staticRouteIds(staticRouteIds: JsonField>) = + apply { + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [staticRouteIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).also { + checkKnown("staticRouteIds", it).add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun wheelchairBoarding(wheelchairBoarding: String) = + wheelchairBoarding(JsonField.of(wheelchairBoarding)) + + /** + * Sets [Builder.wheelchairBoarding] to an arbitrary JSON value. + * + * You should usually call [Builder.wheelchairBoarding] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { + this.wheelchairBoarding = wheelchairBoarding + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SearchForStopListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SearchForStopListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveParams.kt new file mode 100644 index 0000000..e92363c --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveParams.kt @@ -0,0 +1,184 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is ShapeRetrieveParams && shapeId == other.shapeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(shapeId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ShapeRetrieveParams{shapeId=$shapeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt new file mode 100644 index 0000000..66447f0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt @@ -0,0 +1,741 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.shape + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class ShapeRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ShapeRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShapeRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(shapeRetrieveResponse: ShapeRetrieveResponse) = apply { + code = shapeRetrieveResponse.code + currentTime = shapeRetrieveResponse.currentTime + text = shapeRetrieveResponse.text + version = shapeRetrieveResponse.version + data = shapeRetrieveResponse.data + additionalProperties = shapeRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ShapeRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ShapeRetrieveResponse = + ShapeRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ShapeRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val length: JsonField, + private val points: JsonField, + private val levels: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("length") @ExcludeMissing length: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + @JsonProperty("levels") @ExcludeMissing levels: JsonField = JsonMissing.of(), + ) : this(length, points, levels, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun length(): Long = length.getRequired("length") + + /** + * Encoded polyline format representing the shape of the path + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun points(): String = points.getRequired("points") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun levels(): Optional = levels.getOptional("levels") + + /** + * Returns the raw JSON value of [length]. + * + * Unlike [length], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + + /** + * Returns the raw JSON value of [points]. + * + * Unlike [points], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points + + /** + * Returns the raw JSON value of [levels]. + * + * Unlike [levels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .length() + * .points() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var length: JsonField? = null + private var points: JsonField? = null + private var levels: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + length = entry.length + points = entry.points + levels = entry.levels + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun length(length: Long) = length(JsonField.of(length)) + + /** + * Sets [Builder.length] to an arbitrary JSON value. + * + * You should usually call [Builder.length] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun length(length: JsonField) = apply { this.length = length } + + /** Encoded polyline format representing the shape of the path */ + fun points(points: String) = points(JsonField.of(points)) + + /** + * Sets [Builder.points] to an arbitrary JSON value. + * + * You should usually call [Builder.points] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun points(points: JsonField) = apply { this.points = points } + + fun levels(levels: String) = levels(JsonField.of(levels)) + + /** + * Sets [Builder.levels] to an arbitrary JSON value. + * + * You should usually call [Builder.levels] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun levels(levels: JsonField) = apply { this.levels = levels } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .length() + * .points() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("length", length), + checkRequired("points", points), + levels, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + length() + points() + levels() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (length.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && length == other.length && points == other.points && levels == other.levels && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, points, levels, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{length=$length, points=$points, levels=$levels, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ShapeRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ShapeRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveParams.kt new file mode 100644 index 0000000..c734e7b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveParams.kt @@ -0,0 +1,184 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is StopRetrieveParams && stopId == other.stopId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopRetrieveParams{stopId=$stopId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt new file mode 100644 index 0000000..559d930 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt @@ -0,0 +1,1079 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stop + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class StopRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopRetrieveResponse: StopRetrieveResponse) = apply { + code = stopRetrieveResponse.code + currentTime = stopRetrieveResponse.currentTime + text = stopRetrieveResponse.text + version = stopRetrieveResponse.version + data = stopRetrieveResponse.data + additionalProperties = stopRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopRetrieveResponse = + StopRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Double = lat.getRequired("lat") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun locationType(): Long = locationType.getRequired("locationType") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Double = lon.getRequired("lon") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun parent(): String = parent.getRequired("parent") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun routeIds(): List = routeIds.getRequired("routeIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun code(): Optional = code.getOptional("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun direction(): Optional = direction.getOptional("direction") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun wheelchairBoarding(): Optional = + wheelchairBoarding.getOptional("wheelchairBoarding") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [locationType]. + * + * Unlike [locationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + + /** + * Returns the raw JSON value of [routeIds]. + * + * Unlike [routeIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds + + /** + * Returns the raw JSON value of [staticRouteIds]. + * + * Unlike [staticRouteIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [wheelchairBoarding]. + * + * Unlike [wheelchairBoarding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + fun _wheelchairBoarding(): JsonField = wheelchairBoarding + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var lat: JsonField? = null + private var locationType: JsonField? = null + private var lon: JsonField? = null + private var name: JsonField? = null + private var parent: JsonField? = null + private var routeIds: JsonField>? = null + private var staticRouteIds: JsonField>? = null + private var code: JsonField = JsonMissing.of() + private var direction: JsonField = JsonMissing.of() + private var wheelchairBoarding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + lat = entry.lat + locationType = entry.locationType + lon = entry.lon + name = entry.name + parent = entry.parent + routeIds = entry.routeIds.map { it.toMutableList() } + staticRouteIds = entry.staticRouteIds.map { it.toMutableList() } + code = entry.code + direction = entry.direction + wheelchairBoarding = entry.wheelchairBoarding + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + /** + * Sets [Builder.locationType] to an arbitrary JSON value. + * + * You should usually call [Builder.locationType] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun parent(parent: String) = parent(JsonField.of(parent)) + + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) + + /** + * Sets [Builder.routeIds] to an arbitrary JSON value. + * + * You should usually call [Builder.routeIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeIds(routeIds: JsonField>) = apply { + this.routeIds = routeIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [routeIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).also { + checkKnown("routeIds", it).add(routeId) + } + } + + fun staticRouteIds(staticRouteIds: List) = + staticRouteIds(JsonField.of(staticRouteIds)) + + /** + * Sets [Builder.staticRouteIds] to an arbitrary JSON value. + * + * You should usually call [Builder.staticRouteIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun staticRouteIds(staticRouteIds: JsonField>) = apply { + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [staticRouteIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).also { + checkKnown("staticRouteIds", it).add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun wheelchairBoarding(wheelchairBoarding: String) = + wheelchairBoarding(JsonField.of(wheelchairBoarding)) + + /** + * Sets [Builder.wheelchairBoarding] to an arbitrary JSON value. + * + * You should usually call [Builder.wheelchairBoarding] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { + this.wheelchairBoarding = wheelchairBoarding + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParams.kt new file mode 100644 index 0000000..b82ad9d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParams.kt @@ -0,0 +1,190 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is StopIdsForAgencyListParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt new file mode 100644 index 0000000..75f6f06 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt @@ -0,0 +1,565 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopidsforagency + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class StopIdsForAgencyListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopIdsForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopIdsForAgencyListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopIdsForAgencyListResponse: StopIdsForAgencyListResponse) = apply { + code = stopIdsForAgencyListResponse.code + currentTime = stopIdsForAgencyListResponse.currentTime + text = stopIdsForAgencyListResponse.text + version = stopIdsForAgencyListResponse.version + data = stopIdsForAgencyListResponse.data + additionalProperties = stopIdsForAgencyListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopIdsForAgencyListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopIdsForAgencyListResponse = + StopIdsForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopIdsForAgencyListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: String) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.size ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopIdsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopIdsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParams.kt new file mode 100644 index 0000000..434a1bb --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParams.kt @@ -0,0 +1,188 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is StopsForAgencyListParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt new file mode 100644 index 0000000..8e3f66e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt @@ -0,0 +1,1005 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforagency + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class StopsForAgencyListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val outOfRange: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + ) : this( + code, + currentTime, + text, + version, + limitExceeded, + list, + references, + outOfRange, + mutableMapOf(), + ) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + /** + * Returns the raw JSON value of [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange(): JsonField = outOfRange + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopsForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForAgencyListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var outOfRange: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopsForAgencyListResponse: StopsForAgencyListResponse) = apply { + code = stopsForAgencyListResponse.code + currentTime = stopsForAgencyListResponse.currentTime + text = stopsForAgencyListResponse.text + version = stopsForAgencyListResponse.version + limitExceeded = stopsForAgencyListResponse.limitExceeded + list = stopsForAgencyListResponse.list.map { it.toMutableList() } + references = stopsForAgencyListResponse.references + outOfRange = stopsForAgencyListResponse.outOfRange + additionalProperties = stopsForAgencyListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { this.references = references } + + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + /** + * Sets [Builder.outOfRange] to an arbitrary JSON value. + * + * You should usually call [Builder.outOfRange] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopsForAgencyListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopsForAgencyListResponse = + StopsForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + outOfRange, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopsForAgencyListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + class List + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") @ExcludeMissing parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lat(): Double = lat.getRequired("lat") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun locationType(): Long = locationType.getRequired("locationType") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lon(): Double = lon.getRequired("lon") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun parent(): String = parent.getRequired("parent") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun staticRouteIds(): kotlin.collections.List = + staticRouteIds.getRequired("staticRouteIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun code(): Optional = code.getOptional("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun direction(): Optional = direction.getOptional("direction") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun wheelchairBoarding(): Optional = + wheelchairBoarding.getOptional("wheelchairBoarding") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [locationType]. + * + * Unlike [locationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + + /** + * Returns the raw JSON value of [routeIds]. + * + * Unlike [routeIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds + + /** + * Returns the raw JSON value of [staticRouteIds]. + * + * Unlike [staticRouteIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("direction") @ExcludeMissing fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [wheelchairBoarding]. + * + * Unlike [wheelchairBoarding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + fun _wheelchairBoarding(): JsonField = wheelchairBoarding + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var lat: JsonField? = null + private var locationType: JsonField? = null + private var lon: JsonField? = null + private var name: JsonField? = null + private var parent: JsonField? = null + private var routeIds: JsonField>? = null + private var staticRouteIds: JsonField>? = null + private var code: JsonField = JsonMissing.of() + private var direction: JsonField = JsonMissing.of() + private var wheelchairBoarding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + lat = list.lat + locationType = list.locationType + lon = list.lon + name = list.name + parent = list.parent + routeIds = list.routeIds.map { it.toMutableList() } + staticRouteIds = list.staticRouteIds.map { it.toMutableList() } + code = list.code + direction = list.direction + wheelchairBoarding = list.wheelchairBoarding + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + /** + * Sets [Builder.locationType] to an arbitrary JSON value. + * + * You should usually call [Builder.locationType] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun parent(parent: String) = parent(JsonField.of(parent)) + + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + fun routeIds(routeIds: kotlin.collections.List) = + routeIds(JsonField.of(routeIds)) + + /** + * Sets [Builder.routeIds] to an arbitrary JSON value. + * + * You should usually call [Builder.routeIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routeIds(routeIds: JsonField>) = apply { + this.routeIds = routeIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [routeIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).also { + checkKnown("routeIds", it).add(routeId) + } + } + + fun staticRouteIds(staticRouteIds: kotlin.collections.List) = + staticRouteIds(JsonField.of(staticRouteIds)) + + /** + * Sets [Builder.staticRouteIds] to an arbitrary JSON value. + * + * You should usually call [Builder.staticRouteIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun staticRouteIds(staticRouteIds: JsonField>) = apply { + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [staticRouteIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).also { + checkKnown("staticRouteIds", it).add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun wheelchairBoarding(wheelchairBoarding: String) = + wheelchairBoarding(JsonField.of(wheelchairBoarding)) + + /** + * Sets [Builder.wheelchairBoarding] to an arbitrary JSON value. + * + * You should usually call [Builder.wheelchairBoarding] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { + this.wheelchairBoarding = wheelchairBoarding + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, limitExceeded, list, references, outOfRange, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt new file mode 100644 index 0000000..41ac407 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt @@ -0,0 +1,286 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is StopsForLocationListParams && lat == other.lat && lon == other.lon && latSpan == other.latSpan && lonSpan == other.lonSpan && query == other.query && radius == other.radius && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(lat, lon, latSpan, lonSpan, query, radius, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopsForLocationListParams{lat=$lat, lon=$lon, latSpan=$latSpan, lonSpan=$lonSpan, query=$query, radius=$radius, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt new file mode 100644 index 0000000..3d00f7a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt @@ -0,0 +1,1175 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforlocation + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class StopsForLocationListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopsForLocationListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForLocationListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopsForLocationListResponse: StopsForLocationListResponse) = apply { + code = stopsForLocationListResponse.code + currentTime = stopsForLocationListResponse.currentTime + text = stopsForLocationListResponse.text + version = stopsForLocationListResponse.version + data = stopsForLocationListResponse.data + additionalProperties = stopsForLocationListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopsForLocationListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopsForLocationListResponse = + StopsForLocationListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopsForLocationListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val outOfRange: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, outOfRange, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + /** + * Returns the raw JSON value of [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var outOfRange: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + outOfRange = data.outOfRange + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + /** + * Sets [Builder.outOfRange] to an arbitrary JSON value. + * + * You should usually call [Builder.outOfRange] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + outOfRange, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + class List + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Double = lat.getRequired("lat") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun locationType(): Long = locationType.getRequired("locationType") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Double = lon.getRequired("lon") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun parent(): String = parent.getRequired("parent") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun staticRouteIds(): kotlin.collections.List = + staticRouteIds.getRequired("staticRouteIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun code(): Optional = code.getOptional("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun direction(): Optional = direction.getOptional("direction") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun wheelchairBoarding(): Optional = + wheelchairBoarding.getOptional("wheelchairBoarding") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [locationType]. + * + * Unlike [locationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + + /** + * Returns the raw JSON value of [routeIds]. + * + * Unlike [routeIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds + + /** + * Returns the raw JSON value of [staticRouteIds]. + * + * Unlike [staticRouteIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [wheelchairBoarding]. + * + * Unlike [wheelchairBoarding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + fun _wheelchairBoarding(): JsonField = wheelchairBoarding + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var lat: JsonField? = null + private var locationType: JsonField? = null + private var lon: JsonField? = null + private var name: JsonField? = null + private var parent: JsonField? = null + private var routeIds: JsonField>? = null + private var staticRouteIds: JsonField>? = null + private var code: JsonField = JsonMissing.of() + private var direction: JsonField = JsonMissing.of() + private var wheelchairBoarding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + lat = list.lat + locationType = list.locationType + lon = list.lon + name = list.name + parent = list.parent + routeIds = list.routeIds.map { it.toMutableList() } + staticRouteIds = list.staticRouteIds.map { it.toMutableList() } + code = list.code + direction = list.direction + wheelchairBoarding = list.wheelchairBoarding + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + /** + * Sets [Builder.locationType] to an arbitrary JSON value. + * + * You should usually call [Builder.locationType] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun parent(parent: String) = parent(JsonField.of(parent)) + + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + fun routeIds(routeIds: kotlin.collections.List) = + routeIds(JsonField.of(routeIds)) + + /** + * Sets [Builder.routeIds] to an arbitrary JSON value. + * + * You should usually call [Builder.routeIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeIds(routeIds: JsonField>) = apply { + this.routeIds = routeIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [routeIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).also { + checkKnown("routeIds", it).add(routeId) + } + } + + fun staticRouteIds(staticRouteIds: kotlin.collections.List) = + staticRouteIds(JsonField.of(staticRouteIds)) + + /** + * Sets [Builder.staticRouteIds] to an arbitrary JSON value. + * + * You should usually call [Builder.staticRouteIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun staticRouteIds(staticRouteIds: JsonField>) = + apply { + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [staticRouteIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).also { + checkKnown("staticRouteIds", it).add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun wheelchairBoarding(wheelchairBoarding: String) = + wheelchairBoarding(JsonField.of(wheelchairBoarding)) + + /** + * Sets [Builder.wheelchairBoarding] to an arbitrary JSON value. + * + * You should usually call [Builder.wheelchairBoarding] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { + this.wheelchairBoarding = wheelchairBoarding + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopsForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopsForLocationListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParams.kt new file mode 100644 index 0000000..21605fc --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParams.kt @@ -0,0 +1,232 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is StopsForRouteListParams && routeId == other.routeId && includePolylines == other.includePolylines && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(routeId, includePolylines, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopsForRouteListParams{routeId=$routeId, includePolylines=$includePolylines, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt new file mode 100644 index 0000000..8dbd809 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt @@ -0,0 +1,1753 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforroute + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class StopsForRouteListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopsForRouteListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForRouteListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopsForRouteListResponse: StopsForRouteListResponse) = apply { + code = stopsForRouteListResponse.code + currentTime = stopsForRouteListResponse.currentTime + text = stopsForRouteListResponse.text + version = stopsForRouteListResponse.version + data = stopsForRouteListResponse.data + additionalProperties = stopsForRouteListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopsForRouteListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopsForRouteListResponse = + StopsForRouteListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopsForRouteListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val polylines: JsonField>, + private val routeId: JsonField, + private val stopGroupings: JsonField>, + private val stopIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("polylines") + @ExcludeMissing + polylines: JsonField> = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopGroupings") + @ExcludeMissing + stopGroupings: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + stopIds: JsonField> = JsonMissing.of(), + ) : this(polylines, routeId, stopGroupings, stopIds, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun polylines(): Optional> = polylines.getOptional("polylines") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun routeId(): Optional = routeId.getOptional("routeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun stopGroupings(): Optional> = + stopGroupings.getOptional("stopGroupings") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun stopIds(): Optional> = stopIds.getOptional("stopIds") + + /** + * Returns the raw JSON value of [polylines]. + * + * Unlike [polylines], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("polylines") + @ExcludeMissing + fun _polylines(): JsonField> = polylines + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [stopGroupings]. + * + * Unlike [stopGroupings], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopGroupings") + @ExcludeMissing + fun _stopGroupings(): JsonField> = stopGroupings + + /** + * Returns the raw JSON value of [stopIds]. + * + * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Entry]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var polylines: JsonField>? = null + private var routeId: JsonField = JsonMissing.of() + private var stopGroupings: JsonField>? = null + private var stopIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + polylines = entry.polylines.map { it.toMutableList() } + routeId = entry.routeId + stopGroupings = entry.stopGroupings.map { it.toMutableList() } + stopIds = entry.stopIds.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun polylines(polylines: List) = polylines(JsonField.of(polylines)) + + /** + * Sets [Builder.polylines] to an arbitrary JSON value. + * + * You should usually call [Builder.polylines] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun polylines(polylines: JsonField>) = apply { + this.polylines = polylines.map { it.toMutableList() } + } + + /** + * Adds a single [Polyline] to [polylines]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPolyline(polyline: Polyline) = apply { + polylines = + (polylines ?: JsonField.of(mutableListOf())).also { + checkKnown("polylines", it).add(polyline) + } + } + + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun stopGroupings(stopGroupings: List) = + stopGroupings(JsonField.of(stopGroupings)) + + /** + * Sets [Builder.stopGroupings] to an arbitrary JSON value. + * + * You should usually call [Builder.stopGroupings] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopGroupings(stopGroupings: JsonField>) = apply { + this.stopGroupings = stopGroupings.map { it.toMutableList() } + } + + /** + * Adds a single [StopGrouping] to [stopGroupings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopGrouping(stopGrouping: StopGrouping) = apply { + stopGroupings = + (stopGroupings ?: JsonField.of(mutableListOf())).also { + checkKnown("stopGroupings", it).add(stopGrouping) + } + } + + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + + /** + * Sets [Builder.stopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.stopIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [stopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Entry = + Entry( + (polylines ?: JsonMissing.of()).map { it.toImmutable() }, + routeId, + (stopGroupings ?: JsonMissing.of()).map { it.toImmutable() }, + (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + polylines().ifPresent { it.forEach { it.validate() } } + routeId() + stopGroupings().ifPresent { it.forEach { it.validate() } } + stopIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (stopGroupings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) + + class Polyline + private constructor( + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("length") + @ExcludeMissing + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun length(): Optional = length.getOptional("length") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun levels(): Optional = levels.getOptional("levels") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun points(): Optional = points.getOptional("points") + + /** + * Returns the raw JSON value of [length]. + * + * Unlike [length], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + + /** + * Returns the raw JSON value of [levels]. + * + * Unlike [levels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels + + /** + * Returns the raw JSON value of [points]. + * + * Unlike [points], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Polyline]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Polyline]. */ + class Builder internal constructor() { + + private var length: JsonField = JsonMissing.of() + private var levels: JsonField = JsonMissing.of() + private var points: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(polyline: Polyline) = apply { + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() + } + + fun length(length: Long) = length(JsonField.of(length)) + + /** + * Sets [Builder.length] to an arbitrary JSON value. + * + * You should usually call [Builder.length] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun length(length: JsonField) = apply { this.length = length } + + fun levels(levels: String) = levels(JsonField.of(levels)) + + /** + * Sets [Builder.levels] to an arbitrary JSON value. + * + * You should usually call [Builder.levels] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun levels(levels: JsonField) = apply { this.levels = levels } + + fun points(points: String) = points(JsonField.of(points)) + + /** + * Sets [Builder.points] to an arbitrary JSON value. + * + * You should usually call [Builder.points] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun points(points: JsonField) = apply { this.points = points } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Polyline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Polyline = + Polyline(length, levels, points, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Polyline = apply { + if (validated) { + return@apply + } + + length() + levels() + points() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Polyline && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + } + + class StopGrouping + private constructor( + private val id: JsonField, + private val name: JsonField, + private val polylines: JsonField>, + private val stopIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("polylines") + @ExcludeMissing + polylines: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + stopIds: JsonField> = JsonMissing.of(), + ) : this(id, name, polylines, stopIds, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun polylines(): Optional> = polylines.getOptional("polylines") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopIds(): Optional> = stopIds.getOptional("stopIds") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [polylines]. + * + * Unlike [polylines], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("polylines") + @ExcludeMissing + fun _polylines(): JsonField> = polylines + + /** + * Returns the raw JSON value of [stopIds]. + * + * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StopGrouping]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopGrouping]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var polylines: JsonField>? = null + private var stopIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopGrouping: StopGrouping) = apply { + id = stopGrouping.id + name = stopGrouping.name + polylines = stopGrouping.polylines.map { it.toMutableList() } + stopIds = stopGrouping.stopIds.map { it.toMutableList() } + additionalProperties = stopGrouping.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun polylines(polylines: List) = polylines(JsonField.of(polylines)) + + /** + * Sets [Builder.polylines] to an arbitrary JSON value. + * + * You should usually call [Builder.polylines] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun polylines(polylines: JsonField>) = apply { + this.polylines = polylines.map { it.toMutableList() } + } + + /** + * Adds a single [Polyline] to [polylines]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPolyline(polyline: Polyline) = apply { + polylines = + (polylines ?: JsonField.of(mutableListOf())).also { + checkKnown("polylines", it).add(polyline) + } + } + + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + + /** + * Sets [Builder.stopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.stopIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [stopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopGrouping]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopGrouping = + StopGrouping( + id, + name, + (polylines ?: JsonMissing.of()).map { it.toImmutable() }, + (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopGrouping = apply { + if (validated) { + return@apply + } + + id() + name().ifPresent { it.validate() } + polylines().ifPresent { it.forEach { it.validate() } } + stopIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) + + class Name + private constructor( + private val name: JsonField, + private val names: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("names") + @ExcludeMissing + names: JsonField> = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + ) : this(name, names, type, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun names(): Optional> = names.getOptional("names") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [names]. + * + * Unlike [names], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("names") + @ExcludeMissing + fun _names(): JsonField> = names + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Name]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Name]. */ + class Builder internal constructor() { + + private var name: JsonField = JsonMissing.of() + private var names: JsonField>? = null + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(name: Name) = apply { + this.name = name.name + names = name.names.map { it.toMutableList() } + type = name.type + additionalProperties = name.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun names(names: List) = names(JsonField.of(names)) + + /** + * Sets [Builder.names] to an arbitrary JSON value. + * + * You should usually call [Builder.names] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun names(names: JsonField>) = apply { + this.names = names.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [names]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addName(name: String) = apply { + names = + (names ?: JsonField.of(mutableListOf())).also { + checkKnown("names", it).add(name) + } + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Name]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Name = + Name( + name, + (names ?: JsonMissing.of()).map { it.toImmutable() }, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + name() + names() + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (names.asKnown().getOrNull()?.size ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Name && name == other.name && names == other.names && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, names, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" + } + + class Polyline + private constructor( + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("length") + @ExcludeMissing + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun length(): Optional = length.getOptional("length") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun levels(): Optional = levels.getOptional("levels") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun points(): Optional = points.getOptional("points") + + /** + * Returns the raw JSON value of [length]. + * + * Unlike [length], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + + /** + * Returns the raw JSON value of [levels]. + * + * Unlike [levels], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("levels") + @ExcludeMissing + fun _levels(): JsonField = levels + + /** + * Returns the raw JSON value of [points]. + * + * Unlike [points], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("points") + @ExcludeMissing + fun _points(): JsonField = points + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Polyline]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Polyline]. */ + class Builder internal constructor() { + + private var length: JsonField = JsonMissing.of() + private var levels: JsonField = JsonMissing.of() + private var points: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(polyline: Polyline) = apply { + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() + } + + fun length(length: Long) = length(JsonField.of(length)) + + /** + * Sets [Builder.length] to an arbitrary JSON value. + * + * You should usually call [Builder.length] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun length(length: JsonField) = apply { this.length = length } + + fun levels(levels: String) = levels(JsonField.of(levels)) + + /** + * Sets [Builder.levels] to an arbitrary JSON value. + * + * You should usually call [Builder.levels] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun levels(levels: JsonField) = apply { this.levels = levels } + + fun points(points: String) = points(JsonField.of(points)) + + /** + * Sets [Builder.points] to an arbitrary JSON value. + * + * You should usually call [Builder.points] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun points(points: JsonField) = apply { this.points = points } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Polyline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Polyline = + Polyline(length, levels, points, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Polyline = apply { + if (validated) { + return@apply + } + + length() + levels() + points() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Polyline && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopGrouping && id == other.id && name == other.name && polylines == other.polylines && stopIds == other.stopIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, polylines, stopIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && polylines == other.polylines && routeId == other.routeId && stopGroupings == other.stopGroupings && stopIds == other.stopIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopsForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopsForRouteListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveParams.kt new file mode 100644 index 0000000..b28e416 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveParams.kt @@ -0,0 +1,184 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is TripRetrieveParams && tripId == other.tripId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(tripId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripRetrieveParams{tripId=$tripId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt new file mode 100644 index 0000000..f264aa5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt @@ -0,0 +1,1051 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.trip + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class TripRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tripRetrieveResponse: TripRetrieveResponse) = apply { + code = tripRetrieveResponse.code + currentTime = tripRetrieveResponse.currentTime + text = tripRetrieveResponse.text + version = tripRetrieveResponse.version + data = tripRetrieveResponse.data + additionalProperties = tripRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripRetrieveResponse = + TripRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val id: JsonField, + private val routeId: JsonField, + private val serviceId: JsonField, + private val blockId: JsonField, + private val directionId: JsonField, + private val peakOffpeak: JsonField, + private val routeShortName: JsonField, + private val shapeId: JsonField, + private val timeZone: JsonField, + private val tripHeadsign: JsonField, + private val tripShortName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("blockId") + @ExcludeMissing + blockId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + directionId: JsonField = JsonMissing.of(), + @JsonProperty("peakOffpeak") + @ExcludeMissing + peakOffpeak: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shapeId") + @ExcludeMissing + shapeId: JsonField = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripShortName") + @ExcludeMissing + tripShortName: JsonField = JsonMissing.of(), + ) : this( + id, + routeId, + serviceId, + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun serviceId(): String = serviceId.getRequired("serviceId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun blockId(): Optional = blockId.getOptional("blockId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun directionId(): Optional = directionId.getOptional("directionId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun peakOffpeak(): Optional = peakOffpeak.getOptional("peakOffpeak") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun routeShortName(): Optional = routeShortName.getOptional("routeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shapeId(): Optional = shapeId.getOptional("shapeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun timeZone(): Optional = timeZone.getOptional("timeZone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tripHeadsign(): Optional = tripHeadsign.getOptional("tripHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tripShortName(): Optional = tripShortName.getOptional("tripShortName") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [serviceId]. + * + * Unlike [serviceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId + + /** + * Returns the raw JSON value of [blockId]. + * + * Unlike [blockId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blockId") @ExcludeMissing fun _blockId(): JsonField = blockId + + /** + * Returns the raw JSON value of [directionId]. + * + * Unlike [directionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("directionId") + @ExcludeMissing + fun _directionId(): JsonField = directionId + + /** + * Returns the raw JSON value of [peakOffpeak]. + * + * Unlike [peakOffpeak], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("peakOffpeak") + @ExcludeMissing + fun _peakOffpeak(): JsonField = peakOffpeak + + /** + * Returns the raw JSON value of [routeShortName]. + * + * Unlike [routeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName + + /** + * Returns the raw JSON value of [shapeId]. + * + * Unlike [shapeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId + + /** + * Returns the raw JSON value of [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") @ExcludeMissing fun _timeZone(): JsonField = timeZone + + /** + * Returns the raw JSON value of [tripHeadsign]. + * + * Unlike [tripHeadsign], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign + + /** + * Returns the raw JSON value of [tripShortName]. + * + * Unlike [tripShortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripShortName") + @ExcludeMissing + fun _tripShortName(): JsonField = tripShortName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .id() + * .routeId() + * .serviceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var routeId: JsonField? = null + private var serviceId: JsonField? = null + private var blockId: JsonField = JsonMissing.of() + private var directionId: JsonField = JsonMissing.of() + private var peakOffpeak: JsonField = JsonMissing.of() + private var routeShortName: JsonField = JsonMissing.of() + private var shapeId: JsonField = JsonMissing.of() + private var timeZone: JsonField = JsonMissing.of() + private var tripHeadsign: JsonField = JsonMissing.of() + private var tripShortName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + routeId = entry.routeId + serviceId = entry.serviceId + blockId = entry.blockId + directionId = entry.directionId + peakOffpeak = entry.peakOffpeak + routeShortName = entry.routeShortName + shapeId = entry.shapeId + timeZone = entry.timeZone + tripHeadsign = entry.tripHeadsign + tripShortName = entry.tripShortName + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + /** + * Sets [Builder.serviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } + + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) + + /** + * Sets [Builder.blockId] to an arbitrary JSON value. + * + * You should usually call [Builder.blockId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + fun directionId(directionId: String) = directionId(JsonField.of(directionId)) + + /** + * Sets [Builder.directionId] to an arbitrary JSON value. + * + * You should usually call [Builder.directionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun directionId(directionId: JsonField) = apply { + this.directionId = directionId + } + + fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) + + /** + * Sets [Builder.peakOffpeak] to an arbitrary JSON value. + * + * You should usually call [Builder.peakOffpeak] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun peakOffpeak(peakOffpeak: JsonField) = apply { + this.peakOffpeak = peakOffpeak + } + + fun routeShortName(routeShortName: String) = + routeShortName(JsonField.of(routeShortName)) + + /** + * Sets [Builder.routeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeShortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeShortName(routeShortName: JsonField) = apply { + this.routeShortName = routeShortName + } + + fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) + + /** + * Sets [Builder.shapeId] to an arbitrary JSON value. + * + * You should usually call [Builder.shapeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } + + fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * Sets [Builder.timeZone] to an arbitrary JSON value. + * + * You should usually call [Builder.timeZone] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + + fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) + + /** + * Sets [Builder.tripHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.tripHeadsign] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripHeadsign(tripHeadsign: JsonField) = apply { + this.tripHeadsign = tripHeadsign + } + + fun tripShortName(tripShortName: String) = + tripShortName(JsonField.of(tripShortName)) + + /** + * Sets [Builder.tripShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.tripShortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripShortName(tripShortName: JsonField) = apply { + this.tripShortName = tripShortName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .routeId() + * .serviceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("routeId", routeId), + checkRequired("serviceId", serviceId), + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (blockId.asKnown().isPresent) 1 else 0) + + (if (directionId.asKnown().isPresent) 1 else 0) + + (if (peakOffpeak.asKnown().isPresent) 1 else 0) + + (if (routeShortName.asKnown().isPresent) 1 else 0) + + (if (shapeId.asKnown().isPresent) 1 else 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (if (tripShortName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, routeId=$routeId, serviceId=$serviceId, blockId=$blockId, directionId=$directionId, peakOffpeak=$peakOffpeak, routeShortName=$routeShortName, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParams.kt new file mode 100644 index 0000000..cae8cf6 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParams.kt @@ -0,0 +1,311 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is TripDetailRetrieveParams && tripId == other.tripId && includeSchedule == other.includeSchedule && includeStatus == other.includeStatus && includeTrip == other.includeTrip && serviceDate == other.serviceDate && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(tripId, includeSchedule, includeStatus, includeTrip, serviceDate, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripDetailRetrieveParams{tripId=$tripId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, includeTrip=$includeTrip, serviceDate=$serviceDate, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt new file mode 100644 index 0000000..06ec303 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt @@ -0,0 +1,3317 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripdetails + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class TripDetailRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripDetailRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripDetailRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tripDetailRetrieveResponse: TripDetailRetrieveResponse) = apply { + code = tripDetailRetrieveResponse.code + currentTime = tripDetailRetrieveResponse.currentTime + text = tripDetailRetrieveResponse.text + version = tripDetailRetrieveResponse.version + data = tripDetailRetrieveResponse.data + additionalProperties = tripDetailRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripDetailRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripDetailRetrieveResponse = + TripDetailRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripDetailRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val tripId: JsonField, + private val frequency: JsonField, + private val schedule: JsonField, + private val serviceDate: JsonField, + private val situationIds: JsonField>, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(tripId, frequency, schedule, serviceDate, situationIds, status, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun schedule(): Optional = schedule.getOptional("schedule") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDate(): Optional = serviceDate.getOptional("serviceDate") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = situationIds.getOptional("situationIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var tripId: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var schedule: JsonField = JsonMissing.of() + private var serviceDate: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + tripId = entry.tripId + frequency = entry.frequency + schedule = entry.schedule + serviceDate = entry.serviceDate + situationIds = entry.situationIds.map { it.toMutableList() } + status = entry.status + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun frequency(frequency: JsonField) = apply { this.frequency = frequency } + + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("tripId", tripId), + frequency, + schedule, + serviceDate, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + tripId() + frequency() + schedule().ifPresent { it.validate() } + serviceDate() + situationIds() + status().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + class Schedule + private constructor( + private val nextTripId: JsonField, + private val previousTripId: JsonField, + private val stopTimes: JsonField>, + private val timeZone: JsonField, + private val frequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("nextTripId") + @ExcludeMissing + nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + ) : this(nextTripId, previousTripId, stopTimes, timeZone, frequency, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun nextTripId(): String = nextTripId.getRequired("nextTripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun previousTripId(): String = previousTripId.getRequired("previousTripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopTimes(): List = stopTimes.getRequired("stopTimes") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun timeZone(): String = timeZone.getRequired("timeZone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Returns the raw JSON value of [nextTripId]. + * + * Unlike [nextTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId + + /** + * Returns the raw JSON value of [previousTripId]. + * + * Unlike [previousTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previousTripId") + @ExcludeMissing + fun _previousTripId(): JsonField = previousTripId + + /** + * Returns the raw JSON value of [stopTimes]. + * + * Unlike [stopTimes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes + + /** + * Returns the raw JSON value of [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Schedule]. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes.map { it.toMutableList() } + timeZone = schedule.timeZone + frequency = schedule.frequency + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) + + /** + * Sets [Builder.nextTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.nextTripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextTripId(nextTripId: JsonField) = apply { + this.nextTripId = nextTripId + } + + fun previousTripId(previousTripId: String) = + previousTripId(JsonField.of(previousTripId)) + + /** + * Sets [Builder.previousTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTripId(previousTripId: JsonField) = apply { + this.previousTripId = previousTripId + } + + fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) + + /** + * Sets [Builder.stopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTimes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTimes(stopTimes: JsonField>) = apply { + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [StopTime] to [stopTimes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTimes", it).add(stopTime) + } + } + + fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * Sets [Builder.timeZone] to an arbitrary JSON value. + * + * You should usually call [Builder.timeZone] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), + frequency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schedule = apply { + if (validated) { + return@apply + } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (nextTripId.asKnown().isPresent) 1 else 0) + + (if (previousTripId.asKnown().isPresent) 1 else 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceAlongTrip(): Optional = + distanceAlongTrip.getOptional("distanceAlongTrip") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun historicalOccupancy(): Optional = + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopHeadsign(): Optional = stopHeadsign.getOptional("stopHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopId(): Optional = stopId.getOptional("stopId") + + /** + * Returns the raw JSON value of [arrivalTime]. + * + * Unlike [arrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime + + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [historicalOccupancy]. + * + * Unlike [historicalOccupancy], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** + * Returns the raw JSON value of [stopHeadsign]. + * + * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StopTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField = JsonMissing.of() + private var departureTime: JsonField = JsonMissing.of() + private var distanceAlongTrip: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) + + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } + + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) + + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } + + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + fun historicalOccupancy(historicalOccupancy: String) = + historicalOccupancy(JsonField.of(historicalOccupancy)) + + /** + * Sets [Builder.historicalOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.historicalOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun historicalOccupancy(historicalOccupancy: JsonField) = apply { + this.historicalOccupancy = historicalOccupancy + } + + fun stopHeadsign(stopHeadsign: String) = + stopHeadsign(JsonField.of(stopHeadsign)) + + /** + * Sets [Builder.stopHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.stopHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopHeadsign(stopHeadsign: JsonField) = apply { + this.stopHeadsign = stopHeadsign + } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopTime = + StopTime( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownLocation(): Optional = + lastKnownLocation.getOptional("lastKnownLocation") + + /** + * Last known orientation value received in real-time from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownOrientation(): Optional = + lastKnownOrientation.getOptional("lastKnownOrientation") + + /** + * ID of the next stop the transit vehicle is scheduled to arrive at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStop(): Optional = nextStop.getOptional("nextStop") + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStopTimeOffset(): Optional = + nextStopTimeOffset.getOptional("nextStopTimeOffset") + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("orientation") + + /** + * Current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDistanceAlongTrip(): Optional = + scheduledDistanceAlongTrip.getOptional("scheduledDistanceAlongTrip") + + /** + * References to situation elements (if any) applicable to this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * ID of the transit vehicle currently serving the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vehicleId(): Optional = vehicleId.getOptional("vehicleId") + + /** + * Returns the raw JSON value of [activeTripId]. + * + * Unlike [activeTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [closestStop]. + * + * Unlike [closestStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [lastKnownDistanceAlongTrip]. + * + * Unlike [lastKnownDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [scheduleDeviation]. + * + * Unlike [scheduleDeviation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduleDeviation") + @ExcludeMissing + fun _scheduleDeviation(): JsonField = scheduleDeviation + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [totalDistanceAlongTrip]. + * + * Unlike [totalDistanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Returns the raw JSON value of [closestStopTimeOffset]. + * + * Unlike [closestStopTimeOffset], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [lastKnownLocation]. + * + * Unlike [lastKnownLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Returns the raw JSON value of [lastKnownOrientation]. + * + * Unlike [lastKnownOrientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** + * Returns the raw JSON value of [nextStop]. + * + * Unlike [nextStop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Returns the raw JSON value of [nextStopTimeOffset]. + * + * Unlike [nextStopTimeOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [scheduledDistanceAlongTrip]. + * + * Unlike [scheduledDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Status]. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Status]. */ + class Builder internal constructor() { + + private var activeTripId: JsonField? = null + private var blockTripSequence: JsonField? = null + private var closestStop: JsonField? = null + private var distanceAlongTrip: JsonField? = null + private var lastKnownDistanceAlongTrip: JsonField? = null + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var occupancyCapacity: JsonField? = null + private var occupancyCount: JsonField? = null + private var occupancyStatus: JsonField? = null + private var phase: JsonField? = null + private var predicted: JsonField? = null + private var scheduleDeviation: JsonField? = null + private var serviceDate: JsonField? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null + private var closestStopTimeOffset: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var lastKnownLocation: JsonField = JsonMissing.of() + private var lastKnownOrientation: JsonField = JsonMissing.of() + private var nextStop: JsonField = JsonMissing.of() + private var nextStopTimeOffset: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var vehicleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(status: Status) = apply { + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + distanceAlongTrip = status.distanceAlongTrip + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + phase = status.phase + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + serviceDate = status.serviceDate + this.status = status.status + totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } + vehicleId = status.vehicleId + additionalProperties = status.additionalProperties.toMutableMap() + } + + /** Trip ID of the trip the vehicle is actively serving. */ + fun activeTripId(activeTripId: String) = + activeTripId(JsonField.of(activeTripId)) + + /** + * Sets [Builder.activeTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.activeTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun activeTripId(activeTripId: JsonField) = apply { + this.activeTripId = activeTripId + } + + /** Index of the active trip into the sequence of trips for the active block. */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** ID of the closest stop to the current location of the transit vehicle. */ + fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) + + /** + * Sets [Builder.closestStop] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStop(closestStop: JsonField) = apply { + this.closestStop = closestStop + } + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + */ + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = + lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) + + /** + * Sets [Builder.lastKnownDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = + apply { + this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip + } + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + /** Timestamp of the last known real-time update from the transit vehicle. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Capacity of the transit vehicle in terms of occupancy. */ + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + /** Current count of occupants in the transit vehicle. */ + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Current journey phase of the trip. */ + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + */ + fun scheduleDeviation(scheduleDeviation: Long) = + scheduleDeviation(JsonField.of(scheduleDeviation)) + + /** + * Sets [Builder.scheduleDeviation] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDeviation] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduleDeviation(scheduleDeviation: JsonField) = apply { + this.scheduleDeviation = scheduleDeviation + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** Current status modifiers for the trip. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total length of the trip, in meters. */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = + totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) + + /** + * Sets [Builder.totalDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDistanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { + this.totalDistanceAlongTrip = totalDistanceAlongTrip + } + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(closestStopTimeOffset: Long) = + closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) + + /** + * Sets [Builder.closestStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { + this.closestStopTimeOffset = closestStopTimeOffset + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownLocation] with a well-typed + * [LastKnownLocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownLocation(lastKnownLocation: JsonField) = apply { + this.lastKnownLocation = lastKnownLocation + } + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + fun lastKnownOrientation(lastKnownOrientation: Double) = + lastKnownOrientation(JsonField.of(lastKnownOrientation)) + + /** + * Sets [Builder.lastKnownOrientation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownOrientation] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { + this.lastKnownOrientation = lastKnownOrientation + } + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) + + /** + * Sets [Builder.nextStop] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + fun nextStopTimeOffset(nextStopTimeOffset: Long) = + nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) + + /** + * Sets [Builder.nextStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStopTimeOffset] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { + this.nextStopTimeOffset = nextStopTimeOffset + } + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = + scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) + + /** + * Sets [Builder.scheduledDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Status]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Status = + Status( + checkRequired("activeTripId", activeTripId), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("closestStop", closestStop), + checkRequired("distanceAlongTrip", distanceAlongTrip), + checkRequired("lastKnownDistanceAlongTrip", lastKnownDistanceAlongTrip), + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("occupancyCapacity", occupancyCapacity), + checkRequired("occupancyCount", occupancyCount), + checkRequired("occupancyStatus", occupancyStatus), + checkRequired("phase", phase), + checkRequired("predicted", predicted), + checkRequired("scheduleDeviation", scheduleDeviation), + checkRequired("serviceDate", serviceDate), + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + vehicleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + activeTripId() + blockTripSequence() + closestStop() + distanceAlongTrip() + lastKnownDistanceAlongTrip() + lastLocationUpdateTime() + lastUpdateTime() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + predicted() + scheduleDeviation() + serviceDate() + status() + totalDistanceAlongTrip() + closestStopTimeOffset() + frequency() + lastKnownLocation().ifPresent { it.validate() } + lastKnownOrientation() + nextStop() + nextStopTimeOffset() + orientation() + position().ifPresent { it.validate() } + scheduledDistanceAlongTrip() + situationIds() + vehicleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (activeTripId.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (closestStop.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastKnownDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (scheduleDeviation.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (totalDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (closestStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (lastKnownLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastKnownOrientation.asKnown().isPresent) 1 else 0) + + (if (nextStop.asKnown().isPresent) 1 else 0) + + (if (nextStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + + (if (scheduledDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + /** Last known location of the transit vehicle. */ + class LastKnownLocation + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && distanceAlongTrip == other.distanceAlongTrip && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && serviceDate == other.serviceDate && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && closestStopTimeOffset == other.closestStopTimeOffset && frequency == other.frequency && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && orientation == other.orientation && position == other.position && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && situationIds == other.situationIds && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, distanceAlongTrip, lastKnownDistanceAlongTrip, lastLocationUpdateTime, lastUpdateTime, occupancyCapacity, occupancyCount, occupancyStatus, phase, predicted, scheduleDeviation, serviceDate, status, totalDistanceAlongTrip, closestStopTimeOffset, frequency, lastKnownLocation, lastKnownOrientation, nextStop, nextStopTimeOffset, orientation, position, scheduledDistanceAlongTrip, situationIds, vehicleId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && tripId == other.tripId && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tripId, frequency, schedule, serviceDate, situationIds, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{tripId=$tripId, frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripDetailRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripDetailRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParams.kt new file mode 100644 index 0000000..66e38ac --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParams.kt @@ -0,0 +1,301 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is TripForVehicleRetrieveParams && vehicleId == other.vehicleId && includeSchedule == other.includeSchedule && includeStatus == other.includeStatus && includeTrip == other.includeTrip && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(vehicleId, includeSchedule, includeStatus, includeTrip, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripForVehicleRetrieveParams{vehicleId=$vehicleId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, includeTrip=$includeTrip, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt new file mode 100644 index 0000000..62e25fa --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt @@ -0,0 +1,3319 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripforvehicle + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class TripForVehicleRetrieveResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TripForVehicleRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripForVehicleRetrieveResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tripForVehicleRetrieveResponse: TripForVehicleRetrieveResponse) = apply { + code = tripForVehicleRetrieveResponse.code + currentTime = tripForVehicleRetrieveResponse.currentTime + text = tripForVehicleRetrieveResponse.text + version = tripForVehicleRetrieveResponse.version + data = tripForVehicleRetrieveResponse.data + additionalProperties = + tripForVehicleRetrieveResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripForVehicleRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripForVehicleRetrieveResponse = + TripForVehicleRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripForVehicleRetrieveResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val tripId: JsonField, + private val frequency: JsonField, + private val schedule: JsonField, + private val serviceDate: JsonField, + private val situationIds: JsonField>, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(tripId, frequency, schedule, serviceDate, situationIds, status, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun schedule(): Optional = schedule.getOptional("schedule") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDate(): Optional = serviceDate.getOptional("serviceDate") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = situationIds.getOptional("situationIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var tripId: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var schedule: JsonField = JsonMissing.of() + private var serviceDate: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + tripId = entry.tripId + frequency = entry.frequency + schedule = entry.schedule + serviceDate = entry.serviceDate + situationIds = entry.situationIds.map { it.toMutableList() } + status = entry.status + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun frequency(frequency: JsonField) = apply { this.frequency = frequency } + + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("tripId", tripId), + frequency, + schedule, + serviceDate, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + tripId() + frequency() + schedule().ifPresent { it.validate() } + serviceDate() + situationIds() + status().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + class Schedule + private constructor( + private val nextTripId: JsonField, + private val previousTripId: JsonField, + private val stopTimes: JsonField>, + private val timeZone: JsonField, + private val frequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("nextTripId") + @ExcludeMissing + nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + ) : this(nextTripId, previousTripId, stopTimes, timeZone, frequency, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun nextTripId(): String = nextTripId.getRequired("nextTripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun previousTripId(): String = previousTripId.getRequired("previousTripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopTimes(): List = stopTimes.getRequired("stopTimes") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun timeZone(): String = timeZone.getRequired("timeZone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Returns the raw JSON value of [nextTripId]. + * + * Unlike [nextTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId + + /** + * Returns the raw JSON value of [previousTripId]. + * + * Unlike [previousTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previousTripId") + @ExcludeMissing + fun _previousTripId(): JsonField = previousTripId + + /** + * Returns the raw JSON value of [stopTimes]. + * + * Unlike [stopTimes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes + + /** + * Returns the raw JSON value of [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Schedule]. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes.map { it.toMutableList() } + timeZone = schedule.timeZone + frequency = schedule.frequency + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) + + /** + * Sets [Builder.nextTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.nextTripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextTripId(nextTripId: JsonField) = apply { + this.nextTripId = nextTripId + } + + fun previousTripId(previousTripId: String) = + previousTripId(JsonField.of(previousTripId)) + + /** + * Sets [Builder.previousTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTripId(previousTripId: JsonField) = apply { + this.previousTripId = previousTripId + } + + fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) + + /** + * Sets [Builder.stopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTimes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTimes(stopTimes: JsonField>) = apply { + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [StopTime] to [stopTimes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTimes", it).add(stopTime) + } + } + + fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * Sets [Builder.timeZone] to an arbitrary JSON value. + * + * You should usually call [Builder.timeZone] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), + frequency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schedule = apply { + if (validated) { + return@apply + } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (nextTripId.asKnown().isPresent) 1 else 0) + + (if (previousTripId.asKnown().isPresent) 1 else 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceAlongTrip(): Optional = + distanceAlongTrip.getOptional("distanceAlongTrip") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun historicalOccupancy(): Optional = + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopHeadsign(): Optional = stopHeadsign.getOptional("stopHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopId(): Optional = stopId.getOptional("stopId") + + /** + * Returns the raw JSON value of [arrivalTime]. + * + * Unlike [arrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime + + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [historicalOccupancy]. + * + * Unlike [historicalOccupancy], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** + * Returns the raw JSON value of [stopHeadsign]. + * + * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StopTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField = JsonMissing.of() + private var departureTime: JsonField = JsonMissing.of() + private var distanceAlongTrip: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) + + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } + + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) + + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } + + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + fun historicalOccupancy(historicalOccupancy: String) = + historicalOccupancy(JsonField.of(historicalOccupancy)) + + /** + * Sets [Builder.historicalOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.historicalOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun historicalOccupancy(historicalOccupancy: JsonField) = apply { + this.historicalOccupancy = historicalOccupancy + } + + fun stopHeadsign(stopHeadsign: String) = + stopHeadsign(JsonField.of(stopHeadsign)) + + /** + * Sets [Builder.stopHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.stopHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopHeadsign(stopHeadsign: JsonField) = apply { + this.stopHeadsign = stopHeadsign + } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopTime = + StopTime( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownLocation(): Optional = + lastKnownLocation.getOptional("lastKnownLocation") + + /** + * Last known orientation value received in real-time from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownOrientation(): Optional = + lastKnownOrientation.getOptional("lastKnownOrientation") + + /** + * ID of the next stop the transit vehicle is scheduled to arrive at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStop(): Optional = nextStop.getOptional("nextStop") + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStopTimeOffset(): Optional = + nextStopTimeOffset.getOptional("nextStopTimeOffset") + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("orientation") + + /** + * Current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDistanceAlongTrip(): Optional = + scheduledDistanceAlongTrip.getOptional("scheduledDistanceAlongTrip") + + /** + * References to situation elements (if any) applicable to this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * ID of the transit vehicle currently serving the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vehicleId(): Optional = vehicleId.getOptional("vehicleId") + + /** + * Returns the raw JSON value of [activeTripId]. + * + * Unlike [activeTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [closestStop]. + * + * Unlike [closestStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [lastKnownDistanceAlongTrip]. + * + * Unlike [lastKnownDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [scheduleDeviation]. + * + * Unlike [scheduleDeviation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduleDeviation") + @ExcludeMissing + fun _scheduleDeviation(): JsonField = scheduleDeviation + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [totalDistanceAlongTrip]. + * + * Unlike [totalDistanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Returns the raw JSON value of [closestStopTimeOffset]. + * + * Unlike [closestStopTimeOffset], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [lastKnownLocation]. + * + * Unlike [lastKnownLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Returns the raw JSON value of [lastKnownOrientation]. + * + * Unlike [lastKnownOrientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** + * Returns the raw JSON value of [nextStop]. + * + * Unlike [nextStop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Returns the raw JSON value of [nextStopTimeOffset]. + * + * Unlike [nextStopTimeOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [scheduledDistanceAlongTrip]. + * + * Unlike [scheduledDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Status]. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Status]. */ + class Builder internal constructor() { + + private var activeTripId: JsonField? = null + private var blockTripSequence: JsonField? = null + private var closestStop: JsonField? = null + private var distanceAlongTrip: JsonField? = null + private var lastKnownDistanceAlongTrip: JsonField? = null + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var occupancyCapacity: JsonField? = null + private var occupancyCount: JsonField? = null + private var occupancyStatus: JsonField? = null + private var phase: JsonField? = null + private var predicted: JsonField? = null + private var scheduleDeviation: JsonField? = null + private var serviceDate: JsonField? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null + private var closestStopTimeOffset: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var lastKnownLocation: JsonField = JsonMissing.of() + private var lastKnownOrientation: JsonField = JsonMissing.of() + private var nextStop: JsonField = JsonMissing.of() + private var nextStopTimeOffset: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var vehicleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(status: Status) = apply { + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + distanceAlongTrip = status.distanceAlongTrip + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + phase = status.phase + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + serviceDate = status.serviceDate + this.status = status.status + totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } + vehicleId = status.vehicleId + additionalProperties = status.additionalProperties.toMutableMap() + } + + /** Trip ID of the trip the vehicle is actively serving. */ + fun activeTripId(activeTripId: String) = + activeTripId(JsonField.of(activeTripId)) + + /** + * Sets [Builder.activeTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.activeTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun activeTripId(activeTripId: JsonField) = apply { + this.activeTripId = activeTripId + } + + /** Index of the active trip into the sequence of trips for the active block. */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** ID of the closest stop to the current location of the transit vehicle. */ + fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) + + /** + * Sets [Builder.closestStop] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStop(closestStop: JsonField) = apply { + this.closestStop = closestStop + } + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + */ + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = + lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) + + /** + * Sets [Builder.lastKnownDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = + apply { + this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip + } + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + /** Timestamp of the last known real-time update from the transit vehicle. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Capacity of the transit vehicle in terms of occupancy. */ + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + /** Current count of occupants in the transit vehicle. */ + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Current journey phase of the trip. */ + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + */ + fun scheduleDeviation(scheduleDeviation: Long) = + scheduleDeviation(JsonField.of(scheduleDeviation)) + + /** + * Sets [Builder.scheduleDeviation] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDeviation] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduleDeviation(scheduleDeviation: JsonField) = apply { + this.scheduleDeviation = scheduleDeviation + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** Current status modifiers for the trip. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total length of the trip, in meters. */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = + totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) + + /** + * Sets [Builder.totalDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDistanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { + this.totalDistanceAlongTrip = totalDistanceAlongTrip + } + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(closestStopTimeOffset: Long) = + closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) + + /** + * Sets [Builder.closestStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { + this.closestStopTimeOffset = closestStopTimeOffset + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownLocation] with a well-typed + * [LastKnownLocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownLocation(lastKnownLocation: JsonField) = apply { + this.lastKnownLocation = lastKnownLocation + } + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + fun lastKnownOrientation(lastKnownOrientation: Double) = + lastKnownOrientation(JsonField.of(lastKnownOrientation)) + + /** + * Sets [Builder.lastKnownOrientation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownOrientation] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { + this.lastKnownOrientation = lastKnownOrientation + } + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) + + /** + * Sets [Builder.nextStop] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + fun nextStopTimeOffset(nextStopTimeOffset: Long) = + nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) + + /** + * Sets [Builder.nextStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStopTimeOffset] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { + this.nextStopTimeOffset = nextStopTimeOffset + } + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = + scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) + + /** + * Sets [Builder.scheduledDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Status]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Status = + Status( + checkRequired("activeTripId", activeTripId), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("closestStop", closestStop), + checkRequired("distanceAlongTrip", distanceAlongTrip), + checkRequired("lastKnownDistanceAlongTrip", lastKnownDistanceAlongTrip), + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("occupancyCapacity", occupancyCapacity), + checkRequired("occupancyCount", occupancyCount), + checkRequired("occupancyStatus", occupancyStatus), + checkRequired("phase", phase), + checkRequired("predicted", predicted), + checkRequired("scheduleDeviation", scheduleDeviation), + checkRequired("serviceDate", serviceDate), + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + vehicleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + activeTripId() + blockTripSequence() + closestStop() + distanceAlongTrip() + lastKnownDistanceAlongTrip() + lastLocationUpdateTime() + lastUpdateTime() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + predicted() + scheduleDeviation() + serviceDate() + status() + totalDistanceAlongTrip() + closestStopTimeOffset() + frequency() + lastKnownLocation().ifPresent { it.validate() } + lastKnownOrientation() + nextStop() + nextStopTimeOffset() + orientation() + position().ifPresent { it.validate() } + scheduledDistanceAlongTrip() + situationIds() + vehicleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (activeTripId.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (closestStop.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastKnownDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (scheduleDeviation.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (totalDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (closestStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (lastKnownLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastKnownOrientation.asKnown().isPresent) 1 else 0) + + (if (nextStop.asKnown().isPresent) 1 else 0) + + (if (nextStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + + (if (scheduledDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + /** Last known location of the transit vehicle. */ + class LastKnownLocation + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && distanceAlongTrip == other.distanceAlongTrip && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && serviceDate == other.serviceDate && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && closestStopTimeOffset == other.closestStopTimeOffset && frequency == other.frequency && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && orientation == other.orientation && position == other.position && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && situationIds == other.situationIds && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, distanceAlongTrip, lastKnownDistanceAlongTrip, lastLocationUpdateTime, lastUpdateTime, occupancyCapacity, occupancyCount, occupancyStatus, phase, predicted, scheduleDeviation, serviceDate, status, totalDistanceAlongTrip, closestStopTimeOffset, frequency, lastKnownLocation, lastKnownOrientation, nextStop, nextStopTimeOffset, orientation, position, scheduledDistanceAlongTrip, situationIds, vehicleId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && tripId == other.tripId && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tripId, frequency, schedule, serviceDate, situationIds, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{tripId=$tripId, frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripForVehicleRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripForVehicleRetrieveResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParams.kt new file mode 100644 index 0000000..9bc7aad --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParams.kt @@ -0,0 +1,307 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is TripsForLocationListParams && lat == other.lat && latSpan == other.latSpan && lon == other.lon && lonSpan == other.lonSpan && includeSchedule == other.includeSchedule && includeTrip == other.includeTrip && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(lat, latSpan, lon, lonSpan, includeSchedule, includeTrip, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripsForLocationListParams{lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, includeSchedule=$includeSchedule, includeTrip=$includeTrip, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt new file mode 100644 index 0000000..ca490ce --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt @@ -0,0 +1,3428 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforlocation + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class TripsForLocationListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripsForLocationListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripsForLocationListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tripsForLocationListResponse: TripsForLocationListResponse) = apply { + code = tripsForLocationListResponse.code + currentTime = tripsForLocationListResponse.currentTime + text = tripsForLocationListResponse.text + version = tripsForLocationListResponse.version + data = tripsForLocationListResponse.data + additionalProperties = tripsForLocationListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripsForLocationListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripsForLocationListResponse = + TripsForLocationListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripsForLocationListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val outOfRange: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, outOfRange, mutableMapOf()) + + /** + * Indicates if the limit of trips has been exceeded + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Indicates if the search location is out of range + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + /** + * Returns the raw JSON value of [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var outOfRange: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + outOfRange = data.outOfRange + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Indicates if the limit of trips has been exceeded */ + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + /** Indicates if the search location is out of range */ + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + /** + * Sets [Builder.outOfRange] to an arbitrary JSON value. + * + * You should usually call [Builder.outOfRange] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + outOfRange, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + class List + private constructor( + private val schedule: JsonField, + private val status: JsonField, + private val tripId: JsonField, + private val frequency: JsonField, + private val serviceDate: JsonField, + private val situationIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + ) : this(schedule, status, tripId, frequency, serviceDate, situationIds, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun schedule(): Schedule = schedule.getRequired("schedule") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDate(): Optional = serviceDate.getOptional("serviceDate") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .schedule() + * .status() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var schedule: JsonField? = null + private var status: JsonField? = null + private var tripId: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var serviceDate: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + schedule = list.schedule + status = list.status + tripId = list.tripId + frequency = list.frequency + serviceDate = list.serviceDate + situationIds = list.situationIds.map { it.toMutableList() } + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun frequency(frequency: JsonField) = apply { this.frequency = frequency } + + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + fun situationIds(situationIds: kotlin.collections.List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .schedule() + * .status() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("schedule", schedule), + checkRequired("status", status), + checkRequired("tripId", tripId), + frequency, + serviceDate, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + schedule().validate() + status().validate() + tripId() + frequency() + serviceDate() + situationIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + class Schedule + private constructor( + private val nextTripId: JsonField, + private val previousTripId: JsonField, + private val stopTimes: JsonField>, + private val timeZone: JsonField, + private val frequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("nextTripId") + @ExcludeMissing + nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + ) : this(nextTripId, previousTripId, stopTimes, timeZone, frequency, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun nextTripId(): String = nextTripId.getRequired("nextTripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun previousTripId(): String = previousTripId.getRequired("previousTripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopTimes(): kotlin.collections.List = + stopTimes.getRequired("stopTimes") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun timeZone(): String = timeZone.getRequired("timeZone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Returns the raw JSON value of [nextTripId]. + * + * Unlike [nextTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId + + /** + * Returns the raw JSON value of [previousTripId]. + * + * Unlike [previousTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previousTripId") + @ExcludeMissing + fun _previousTripId(): JsonField = previousTripId + + /** + * Returns the raw JSON value of [stopTimes]. + * + * Unlike [stopTimes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes + + /** + * Returns the raw JSON value of [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Schedule]. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes.map { it.toMutableList() } + timeZone = schedule.timeZone + frequency = schedule.frequency + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) + + /** + * Sets [Builder.nextTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.nextTripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextTripId(nextTripId: JsonField) = apply { + this.nextTripId = nextTripId + } + + fun previousTripId(previousTripId: String) = + previousTripId(JsonField.of(previousTripId)) + + /** + * Sets [Builder.previousTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTripId(previousTripId: JsonField) = apply { + this.previousTripId = previousTripId + } + + fun stopTimes(stopTimes: kotlin.collections.List) = + stopTimes(JsonField.of(stopTimes)) + + /** + * Sets [Builder.stopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTimes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTimes(stopTimes: JsonField>) = apply { + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [StopTime] to [stopTimes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTimes", it).add(stopTime) + } + } + + fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * Sets [Builder.timeZone] to an arbitrary JSON value. + * + * You should usually call [Builder.timeZone] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), + frequency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schedule = apply { + if (validated) { + return@apply + } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (nextTripId.asKnown().isPresent) 1 else 0) + + (if (previousTripId.asKnown().isPresent) 1 else 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceAlongTrip(): Optional = + distanceAlongTrip.getOptional("distanceAlongTrip") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun historicalOccupancy(): Optional = + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopHeadsign(): Optional = stopHeadsign.getOptional("stopHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopId(): Optional = stopId.getOptional("stopId") + + /** + * Returns the raw JSON value of [arrivalTime]. + * + * Unlike [arrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime + + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [historicalOccupancy]. + * + * Unlike [historicalOccupancy], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** + * Returns the raw JSON value of [stopHeadsign]. + * + * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StopTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField = JsonMissing.of() + private var departureTime: JsonField = JsonMissing.of() + private var distanceAlongTrip: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) + + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } + + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) + + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } + + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + fun historicalOccupancy(historicalOccupancy: String) = + historicalOccupancy(JsonField.of(historicalOccupancy)) + + /** + * Sets [Builder.historicalOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.historicalOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun historicalOccupancy(historicalOccupancy: JsonField) = apply { + this.historicalOccupancy = historicalOccupancy + } + + fun stopHeadsign(stopHeadsign: String) = + stopHeadsign(JsonField.of(stopHeadsign)) + + /** + * Sets [Builder.stopHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.stopHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopHeadsign(stopHeadsign: JsonField) = apply { + this.stopHeadsign = stopHeadsign + } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopTime = + StopTime( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownLocation(): Optional = + lastKnownLocation.getOptional("lastKnownLocation") + + /** + * Last known orientation value received in real-time from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownOrientation(): Optional = + lastKnownOrientation.getOptional("lastKnownOrientation") + + /** + * ID of the next stop the transit vehicle is scheduled to arrive at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStop(): Optional = nextStop.getOptional("nextStop") + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStopTimeOffset(): Optional = + nextStopTimeOffset.getOptional("nextStopTimeOffset") + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("orientation") + + /** + * Current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDistanceAlongTrip(): Optional = + scheduledDistanceAlongTrip.getOptional("scheduledDistanceAlongTrip") + + /** + * References to situation elements (if any) applicable to this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * ID of the transit vehicle currently serving the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vehicleId(): Optional = vehicleId.getOptional("vehicleId") + + /** + * Returns the raw JSON value of [activeTripId]. + * + * Unlike [activeTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [closestStop]. + * + * Unlike [closestStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [lastKnownDistanceAlongTrip]. + * + * Unlike [lastKnownDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [scheduleDeviation]. + * + * Unlike [scheduleDeviation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduleDeviation") + @ExcludeMissing + fun _scheduleDeviation(): JsonField = scheduleDeviation + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [totalDistanceAlongTrip]. + * + * Unlike [totalDistanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Returns the raw JSON value of [closestStopTimeOffset]. + * + * Unlike [closestStopTimeOffset], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [lastKnownLocation]. + * + * Unlike [lastKnownLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Returns the raw JSON value of [lastKnownOrientation]. + * + * Unlike [lastKnownOrientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** + * Returns the raw JSON value of [nextStop]. + * + * Unlike [nextStop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Returns the raw JSON value of [nextStopTimeOffset]. + * + * Unlike [nextStopTimeOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [scheduledDistanceAlongTrip]. + * + * Unlike [scheduledDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Status]. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Status]. */ + class Builder internal constructor() { + + private var activeTripId: JsonField? = null + private var blockTripSequence: JsonField? = null + private var closestStop: JsonField? = null + private var distanceAlongTrip: JsonField? = null + private var lastKnownDistanceAlongTrip: JsonField? = null + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var occupancyCapacity: JsonField? = null + private var occupancyCount: JsonField? = null + private var occupancyStatus: JsonField? = null + private var phase: JsonField? = null + private var predicted: JsonField? = null + private var scheduleDeviation: JsonField? = null + private var serviceDate: JsonField? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null + private var closestStopTimeOffset: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var lastKnownLocation: JsonField = JsonMissing.of() + private var lastKnownOrientation: JsonField = JsonMissing.of() + private var nextStop: JsonField = JsonMissing.of() + private var nextStopTimeOffset: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var vehicleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(status: Status) = apply { + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + distanceAlongTrip = status.distanceAlongTrip + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + phase = status.phase + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + serviceDate = status.serviceDate + this.status = status.status + totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } + vehicleId = status.vehicleId + additionalProperties = status.additionalProperties.toMutableMap() + } + + /** Trip ID of the trip the vehicle is actively serving. */ + fun activeTripId(activeTripId: String) = + activeTripId(JsonField.of(activeTripId)) + + /** + * Sets [Builder.activeTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.activeTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun activeTripId(activeTripId: JsonField) = apply { + this.activeTripId = activeTripId + } + + /** Index of the active trip into the sequence of trips for the active block. */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** ID of the closest stop to the current location of the transit vehicle. */ + fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) + + /** + * Sets [Builder.closestStop] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStop(closestStop: JsonField) = apply { + this.closestStop = closestStop + } + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + */ + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = + lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) + + /** + * Sets [Builder.lastKnownDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = + apply { + this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip + } + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + /** Timestamp of the last known real-time update from the transit vehicle. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Capacity of the transit vehicle in terms of occupancy. */ + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + /** Current count of occupants in the transit vehicle. */ + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Current journey phase of the trip. */ + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + */ + fun scheduleDeviation(scheduleDeviation: Long) = + scheduleDeviation(JsonField.of(scheduleDeviation)) + + /** + * Sets [Builder.scheduleDeviation] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDeviation] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduleDeviation(scheduleDeviation: JsonField) = apply { + this.scheduleDeviation = scheduleDeviation + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** Current status modifiers for the trip. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total length of the trip, in meters. */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = + totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) + + /** + * Sets [Builder.totalDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDistanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { + this.totalDistanceAlongTrip = totalDistanceAlongTrip + } + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(closestStopTimeOffset: Long) = + closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) + + /** + * Sets [Builder.closestStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { + this.closestStopTimeOffset = closestStopTimeOffset + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownLocation] with a well-typed + * [LastKnownLocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownLocation(lastKnownLocation: JsonField) = apply { + this.lastKnownLocation = lastKnownLocation + } + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + fun lastKnownOrientation(lastKnownOrientation: Double) = + lastKnownOrientation(JsonField.of(lastKnownOrientation)) + + /** + * Sets [Builder.lastKnownOrientation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownOrientation] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { + this.lastKnownOrientation = lastKnownOrientation + } + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) + + /** + * Sets [Builder.nextStop] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + fun nextStopTimeOffset(nextStopTimeOffset: Long) = + nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) + + /** + * Sets [Builder.nextStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStopTimeOffset] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { + this.nextStopTimeOffset = nextStopTimeOffset + } + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = + scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) + + /** + * Sets [Builder.scheduledDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: kotlin.collections.List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = + apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Status]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Status = + Status( + checkRequired("activeTripId", activeTripId), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("closestStop", closestStop), + checkRequired("distanceAlongTrip", distanceAlongTrip), + checkRequired("lastKnownDistanceAlongTrip", lastKnownDistanceAlongTrip), + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("occupancyCapacity", occupancyCapacity), + checkRequired("occupancyCount", occupancyCount), + checkRequired("occupancyStatus", occupancyStatus), + checkRequired("phase", phase), + checkRequired("predicted", predicted), + checkRequired("scheduleDeviation", scheduleDeviation), + checkRequired("serviceDate", serviceDate), + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + vehicleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + activeTripId() + blockTripSequence() + closestStop() + distanceAlongTrip() + lastKnownDistanceAlongTrip() + lastLocationUpdateTime() + lastUpdateTime() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + predicted() + scheduleDeviation() + serviceDate() + status() + totalDistanceAlongTrip() + closestStopTimeOffset() + frequency() + lastKnownLocation().ifPresent { it.validate() } + lastKnownOrientation() + nextStop() + nextStopTimeOffset() + orientation() + position().ifPresent { it.validate() } + scheduledDistanceAlongTrip() + situationIds() + vehicleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (activeTripId.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (closestStop.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastKnownDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (scheduleDeviation.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (totalDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (closestStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (lastKnownLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastKnownOrientation.asKnown().isPresent) 1 else 0) + + (if (nextStop.asKnown().isPresent) 1 else 0) + + (if (nextStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + + (if (scheduledDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + /** Last known location of the transit vehicle. */ + class LastKnownLocation + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && distanceAlongTrip == other.distanceAlongTrip && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && serviceDate == other.serviceDate && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && closestStopTimeOffset == other.closestStopTimeOffset && frequency == other.frequency && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && orientation == other.orientation && position == other.position && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && situationIds == other.situationIds && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, distanceAlongTrip, lastKnownDistanceAlongTrip, lastLocationUpdateTime, lastUpdateTime, occupancyCapacity, occupancyCount, occupancyStatus, phase, predicted, scheduleDeviation, serviceDate, status, totalDistanceAlongTrip, closestStopTimeOffset, frequency, lastKnownLocation, lastKnownOrientation, nextStop, nextStopTimeOffset, orientation, position, scheduledDistanceAlongTrip, situationIds, vehicleId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && schedule == other.schedule && status == other.status && tripId == other.tripId && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(schedule, status, tripId, frequency, serviceDate, situationIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{schedule=$schedule, status=$status, tripId=$tripId, frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripsForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripsForLocationListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParams.kt new file mode 100644 index 0000000..fcf6831 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParams.kt @@ -0,0 +1,266 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is TripsForRouteListParams && routeId == other.routeId && includeSchedule == other.includeSchedule && includeStatus == other.includeStatus && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(routeId, includeSchedule, includeStatus, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripsForRouteListParams{routeId=$routeId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt new file mode 100644 index 0000000..7dcf7a4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt @@ -0,0 +1,3387 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforroute + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class TripsForRouteListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripsForRouteListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripsForRouteListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tripsForRouteListResponse: TripsForRouteListResponse) = apply { + code = tripsForRouteListResponse.code + currentTime = tripsForRouteListResponse.currentTime + text = tripsForRouteListResponse.text + version = tripsForRouteListResponse.version + data = tripsForRouteListResponse.data + additionalProperties = tripsForRouteListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripsForRouteListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripsForRouteListResponse = + TripsForRouteListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripsForRouteListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val schedule: JsonField, + private val status: JsonField, + private val tripId: JsonField, + private val frequency: JsonField, + private val serviceDate: JsonField, + private val situationIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + ) : this(schedule, status, tripId, frequency, serviceDate, situationIds, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun schedule(): Schedule = schedule.getRequired("schedule") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDate(): Optional = serviceDate.getOptional("serviceDate") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .schedule() + * .status() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var schedule: JsonField? = null + private var status: JsonField? = null + private var tripId: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var serviceDate: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + schedule = list.schedule + status = list.status + tripId = list.tripId + frequency = list.frequency + serviceDate = list.serviceDate + situationIds = list.situationIds.map { it.toMutableList() } + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun frequency(frequency: JsonField) = apply { this.frequency = frequency } + + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + fun situationIds(situationIds: kotlin.collections.List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .schedule() + * .status() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("schedule", schedule), + checkRequired("status", status), + checkRequired("tripId", tripId), + frequency, + serviceDate, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + schedule().validate() + status().validate() + tripId() + frequency() + serviceDate() + situationIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + class Schedule + private constructor( + private val nextTripId: JsonField, + private val previousTripId: JsonField, + private val stopTimes: JsonField>, + private val timeZone: JsonField, + private val frequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("nextTripId") + @ExcludeMissing + nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + ) : this(nextTripId, previousTripId, stopTimes, timeZone, frequency, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun nextTripId(): String = nextTripId.getRequired("nextTripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun previousTripId(): String = previousTripId.getRequired("previousTripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopTimes(): kotlin.collections.List = + stopTimes.getRequired("stopTimes") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun timeZone(): String = timeZone.getRequired("timeZone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Returns the raw JSON value of [nextTripId]. + * + * Unlike [nextTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId + + /** + * Returns the raw JSON value of [previousTripId]. + * + * Unlike [previousTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previousTripId") + @ExcludeMissing + fun _previousTripId(): JsonField = previousTripId + + /** + * Returns the raw JSON value of [stopTimes]. + * + * Unlike [stopTimes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes + + /** + * Returns the raw JSON value of [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Schedule]. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes.map { it.toMutableList() } + timeZone = schedule.timeZone + frequency = schedule.frequency + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) + + /** + * Sets [Builder.nextTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.nextTripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextTripId(nextTripId: JsonField) = apply { + this.nextTripId = nextTripId + } + + fun previousTripId(previousTripId: String) = + previousTripId(JsonField.of(previousTripId)) + + /** + * Sets [Builder.previousTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTripId(previousTripId: JsonField) = apply { + this.previousTripId = previousTripId + } + + fun stopTimes(stopTimes: kotlin.collections.List) = + stopTimes(JsonField.of(stopTimes)) + + /** + * Sets [Builder.stopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTimes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTimes(stopTimes: JsonField>) = apply { + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [StopTime] to [stopTimes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTimes", it).add(stopTime) + } + } + + fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * Sets [Builder.timeZone] to an arbitrary JSON value. + * + * You should usually call [Builder.timeZone] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), + frequency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schedule = apply { + if (validated) { + return@apply + } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (nextTripId.asKnown().isPresent) 1 else 0) + + (if (previousTripId.asKnown().isPresent) 1 else 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceAlongTrip(): Optional = + distanceAlongTrip.getOptional("distanceAlongTrip") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun historicalOccupancy(): Optional = + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopHeadsign(): Optional = stopHeadsign.getOptional("stopHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopId(): Optional = stopId.getOptional("stopId") + + /** + * Returns the raw JSON value of [arrivalTime]. + * + * Unlike [arrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime + + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [historicalOccupancy]. + * + * Unlike [historicalOccupancy], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** + * Returns the raw JSON value of [stopHeadsign]. + * + * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StopTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField = JsonMissing.of() + private var departureTime: JsonField = JsonMissing.of() + private var distanceAlongTrip: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) + + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } + + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) + + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } + + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + fun historicalOccupancy(historicalOccupancy: String) = + historicalOccupancy(JsonField.of(historicalOccupancy)) + + /** + * Sets [Builder.historicalOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.historicalOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun historicalOccupancy(historicalOccupancy: JsonField) = apply { + this.historicalOccupancy = historicalOccupancy + } + + fun stopHeadsign(stopHeadsign: String) = + stopHeadsign(JsonField.of(stopHeadsign)) + + /** + * Sets [Builder.stopHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.stopHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopHeadsign(stopHeadsign: JsonField) = apply { + this.stopHeadsign = stopHeadsign + } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopTime = + StopTime( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownLocation(): Optional = + lastKnownLocation.getOptional("lastKnownLocation") + + /** + * Last known orientation value received in real-time from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownOrientation(): Optional = + lastKnownOrientation.getOptional("lastKnownOrientation") + + /** + * ID of the next stop the transit vehicle is scheduled to arrive at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStop(): Optional = nextStop.getOptional("nextStop") + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStopTimeOffset(): Optional = + nextStopTimeOffset.getOptional("nextStopTimeOffset") + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("orientation") + + /** + * Current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDistanceAlongTrip(): Optional = + scheduledDistanceAlongTrip.getOptional("scheduledDistanceAlongTrip") + + /** + * References to situation elements (if any) applicable to this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * ID of the transit vehicle currently serving the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vehicleId(): Optional = vehicleId.getOptional("vehicleId") + + /** + * Returns the raw JSON value of [activeTripId]. + * + * Unlike [activeTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [closestStop]. + * + * Unlike [closestStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [lastKnownDistanceAlongTrip]. + * + * Unlike [lastKnownDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [scheduleDeviation]. + * + * Unlike [scheduleDeviation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduleDeviation") + @ExcludeMissing + fun _scheduleDeviation(): JsonField = scheduleDeviation + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [totalDistanceAlongTrip]. + * + * Unlike [totalDistanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Returns the raw JSON value of [closestStopTimeOffset]. + * + * Unlike [closestStopTimeOffset], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [lastKnownLocation]. + * + * Unlike [lastKnownLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Returns the raw JSON value of [lastKnownOrientation]. + * + * Unlike [lastKnownOrientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** + * Returns the raw JSON value of [nextStop]. + * + * Unlike [nextStop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Returns the raw JSON value of [nextStopTimeOffset]. + * + * Unlike [nextStopTimeOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [scheduledDistanceAlongTrip]. + * + * Unlike [scheduledDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Status]. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Status]. */ + class Builder internal constructor() { + + private var activeTripId: JsonField? = null + private var blockTripSequence: JsonField? = null + private var closestStop: JsonField? = null + private var distanceAlongTrip: JsonField? = null + private var lastKnownDistanceAlongTrip: JsonField? = null + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var occupancyCapacity: JsonField? = null + private var occupancyCount: JsonField? = null + private var occupancyStatus: JsonField? = null + private var phase: JsonField? = null + private var predicted: JsonField? = null + private var scheduleDeviation: JsonField? = null + private var serviceDate: JsonField? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null + private var closestStopTimeOffset: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var lastKnownLocation: JsonField = JsonMissing.of() + private var lastKnownOrientation: JsonField = JsonMissing.of() + private var nextStop: JsonField = JsonMissing.of() + private var nextStopTimeOffset: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var vehicleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(status: Status) = apply { + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + distanceAlongTrip = status.distanceAlongTrip + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + phase = status.phase + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + serviceDate = status.serviceDate + this.status = status.status + totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } + vehicleId = status.vehicleId + additionalProperties = status.additionalProperties.toMutableMap() + } + + /** Trip ID of the trip the vehicle is actively serving. */ + fun activeTripId(activeTripId: String) = + activeTripId(JsonField.of(activeTripId)) + + /** + * Sets [Builder.activeTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.activeTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun activeTripId(activeTripId: JsonField) = apply { + this.activeTripId = activeTripId + } + + /** Index of the active trip into the sequence of trips for the active block. */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** ID of the closest stop to the current location of the transit vehicle. */ + fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) + + /** + * Sets [Builder.closestStop] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStop(closestStop: JsonField) = apply { + this.closestStop = closestStop + } + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + */ + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = + lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) + + /** + * Sets [Builder.lastKnownDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = + apply { + this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip + } + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + /** Timestamp of the last known real-time update from the transit vehicle. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Capacity of the transit vehicle in terms of occupancy. */ + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + /** Current count of occupants in the transit vehicle. */ + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Current journey phase of the trip. */ + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + */ + fun scheduleDeviation(scheduleDeviation: Long) = + scheduleDeviation(JsonField.of(scheduleDeviation)) + + /** + * Sets [Builder.scheduleDeviation] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDeviation] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduleDeviation(scheduleDeviation: JsonField) = apply { + this.scheduleDeviation = scheduleDeviation + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** Current status modifiers for the trip. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total length of the trip, in meters. */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = + totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) + + /** + * Sets [Builder.totalDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDistanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { + this.totalDistanceAlongTrip = totalDistanceAlongTrip + } + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(closestStopTimeOffset: Long) = + closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) + + /** + * Sets [Builder.closestStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { + this.closestStopTimeOffset = closestStopTimeOffset + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownLocation] with a well-typed + * [LastKnownLocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownLocation(lastKnownLocation: JsonField) = apply { + this.lastKnownLocation = lastKnownLocation + } + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + fun lastKnownOrientation(lastKnownOrientation: Double) = + lastKnownOrientation(JsonField.of(lastKnownOrientation)) + + /** + * Sets [Builder.lastKnownOrientation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownOrientation] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { + this.lastKnownOrientation = lastKnownOrientation + } + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) + + /** + * Sets [Builder.nextStop] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + fun nextStopTimeOffset(nextStopTimeOffset: Long) = + nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) + + /** + * Sets [Builder.nextStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStopTimeOffset] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { + this.nextStopTimeOffset = nextStopTimeOffset + } + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = + scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) + + /** + * Sets [Builder.scheduledDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: kotlin.collections.List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = + apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Status]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Status = + Status( + checkRequired("activeTripId", activeTripId), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("closestStop", closestStop), + checkRequired("distanceAlongTrip", distanceAlongTrip), + checkRequired("lastKnownDistanceAlongTrip", lastKnownDistanceAlongTrip), + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("occupancyCapacity", occupancyCapacity), + checkRequired("occupancyCount", occupancyCount), + checkRequired("occupancyStatus", occupancyStatus), + checkRequired("phase", phase), + checkRequired("predicted", predicted), + checkRequired("scheduleDeviation", scheduleDeviation), + checkRequired("serviceDate", serviceDate), + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + vehicleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + activeTripId() + blockTripSequence() + closestStop() + distanceAlongTrip() + lastKnownDistanceAlongTrip() + lastLocationUpdateTime() + lastUpdateTime() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + predicted() + scheduleDeviation() + serviceDate() + status() + totalDistanceAlongTrip() + closestStopTimeOffset() + frequency() + lastKnownLocation().ifPresent { it.validate() } + lastKnownOrientation() + nextStop() + nextStopTimeOffset() + orientation() + position().ifPresent { it.validate() } + scheduledDistanceAlongTrip() + situationIds() + vehicleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (activeTripId.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (closestStop.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastKnownDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (scheduleDeviation.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (totalDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (closestStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (lastKnownLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastKnownOrientation.asKnown().isPresent) 1 else 0) + + (if (nextStop.asKnown().isPresent) 1 else 0) + + (if (nextStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + + (if (scheduledDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + /** Last known location of the transit vehicle. */ + class LastKnownLocation + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && distanceAlongTrip == other.distanceAlongTrip && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && serviceDate == other.serviceDate && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && closestStopTimeOffset == other.closestStopTimeOffset && frequency == other.frequency && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && orientation == other.orientation && position == other.position && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && situationIds == other.situationIds && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, distanceAlongTrip, lastKnownDistanceAlongTrip, lastLocationUpdateTime, lastUpdateTime, occupancyCapacity, occupancyCount, occupancyStatus, phase, predicted, scheduleDeviation, serviceDate, status, totalDistanceAlongTrip, closestStopTimeOffset, frequency, lastKnownLocation, lastKnownOrientation, nextStop, nextStopTimeOffset, orientation, position, scheduledDistanceAlongTrip, situationIds, vehicleId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && schedule == other.schedule && status == other.status && tripId == other.tripId && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(schedule, status, tripId, frequency, serviceDate, situationIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{schedule=$schedule, status=$status, tripId=$tripId, frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripsForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripsForRouteListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParams.kt new file mode 100644 index 0000000..5398c9c --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParams.kt @@ -0,0 +1,209 @@ +// 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) + + fun _additionalHeaders(): Headers = additionalHeaders + + 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 /* spotless:off */ other is VehiclesForAgencyListParams && agencyId == other.agencyId && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "VehiclesForAgencyListParams{agencyId=$agencyId, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt new file mode 100644 index 0000000..1b3af09 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -0,0 +1,3052 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.vehiclesforagency + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class VehiclesForAgencyListResponse +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [VehiclesForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VehiclesForAgencyListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(vehiclesForAgencyListResponse: VehiclesForAgencyListResponse) = apply { + code = vehiclesForAgencyListResponse.code + currentTime = vehiclesForAgencyListResponse.currentTime + text = vehiclesForAgencyListResponse.text + version = vehiclesForAgencyListResponse.version + data = vehiclesForAgencyListResponse.data + additionalProperties = vehiclesForAgencyListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VehiclesForAgencyListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VehiclesForAgencyListResponse = + VehiclesForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VehiclesForAgencyListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun list(): kotlin.collections.List = list.getRequired("list") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) + } + } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val location: JsonField, + private val tripId: JsonField, + private val tripStatus: JsonField, + private val vehicleId: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + location: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + tripStatus: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") @ExcludeMissing phase: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this( + lastLocationUpdateTime, + lastUpdateTime, + location, + tripId, + tripStatus, + vehicleId, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + status, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun location(): Location = location.getRequired("location") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tripStatus(): TripStatus = tripStatus.getRequired("tripStatus") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun vehicleId(): String = vehicleId.getRequired("vehicleId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun occupancyCapacity(): Optional = + occupancyCapacity.getOptional("occupancyCapacity") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun occupancyCount(): Optional = occupancyCount.getOptional("occupancyCount") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun occupancyStatus(): Optional = occupancyStatus.getOptional("occupancyStatus") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun phase(): Optional = phase.getOptional("phase") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [tripStatus]. + * + * Unlike [tripStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .location() + * .tripId() + * .tripStatus() + * .vehicleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var location: JsonField? = null + private var tripId: JsonField? = null + private var tripStatus: JsonField? = null + private var vehicleId: JsonField? = null + private var occupancyCapacity: JsonField = JsonMissing.of() + private var occupancyCount: JsonField = JsonMissing.of() + private var occupancyStatus: JsonField = JsonMissing.of() + private var phase: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + lastLocationUpdateTime = list.lastLocationUpdateTime + lastUpdateTime = list.lastUpdateTime + location = list.location + tripId = list.tripId + tripStatus = list.tripStatus + vehicleId = list.vehicleId + occupancyCapacity = list.occupancyCapacity + occupancyCount = list.occupancyCount + occupancyStatus = list.occupancyStatus + phase = list.phase + status = list.status + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + fun location(location: Location) = location(JsonField.of(location)) + + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed [Location] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun location(location: JsonField) = apply { this.location = location } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) + + /** + * Sets [Builder.tripStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.tripStatus] with a well-typed [TripStatus] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripStatus(tripStatus: JsonField) = apply { + this.tripStatus = tripStatus + } + + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } + + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .location() + * .tripId() + * .tripStatus() + * .vehicleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("location", location), + checkRequired("tripId", tripId), + checkRequired("tripStatus", tripStatus), + checkRequired("vehicleId", vehicleId), + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + lastLocationUpdateTime() + lastUpdateTime() + location().validate() + tripId() + tripStatus().validate() + vehicleId() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (location.asKnown().getOrNull()?.validity() ?: 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (tripStatus.asKnown().getOrNull()?.validity() ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + class Location + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Location]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Location]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(location: Location) = apply { + lat = location.lat + lon = location.lon + additionalProperties = location.additionalProperties.toMutableMap() + } + + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Location]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Location = Location(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Location = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Location && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Location{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + class TripStatus + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownLocation(): Optional = + lastKnownLocation.getOptional("lastKnownLocation") + + /** + * Last known orientation value received in real-time from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownOrientation(): Optional = + lastKnownOrientation.getOptional("lastKnownOrientation") + + /** + * ID of the next stop the transit vehicle is scheduled to arrive at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStop(): Optional = nextStop.getOptional("nextStop") + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStopTimeOffset(): Optional = + nextStopTimeOffset.getOptional("nextStopTimeOffset") + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("orientation") + + /** + * Current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDistanceAlongTrip(): Optional = + scheduledDistanceAlongTrip.getOptional("scheduledDistanceAlongTrip") + + /** + * References to situation elements (if any) applicable to this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * ID of the transit vehicle currently serving the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vehicleId(): Optional = vehicleId.getOptional("vehicleId") + + /** + * Returns the raw JSON value of [activeTripId]. + * + * Unlike [activeTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [closestStop]. + * + * Unlike [closestStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [lastKnownDistanceAlongTrip]. + * + * Unlike [lastKnownDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [scheduleDeviation]. + * + * Unlike [scheduleDeviation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduleDeviation") + @ExcludeMissing + fun _scheduleDeviation(): JsonField = scheduleDeviation + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [totalDistanceAlongTrip]. + * + * Unlike [totalDistanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Returns the raw JSON value of [closestStopTimeOffset]. + * + * Unlike [closestStopTimeOffset], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [lastKnownLocation]. + * + * Unlike [lastKnownLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Returns the raw JSON value of [lastKnownOrientation]. + * + * Unlike [lastKnownOrientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** + * Returns the raw JSON value of [nextStop]. + * + * Unlike [nextStop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Returns the raw JSON value of [nextStopTimeOffset]. + * + * Unlike [nextStopTimeOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [scheduledDistanceAlongTrip]. + * + * Unlike [scheduledDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripStatus]. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripStatus]. */ + class Builder internal constructor() { + + private var activeTripId: JsonField? = null + private var blockTripSequence: JsonField? = null + private var closestStop: JsonField? = null + private var distanceAlongTrip: JsonField? = null + private var lastKnownDistanceAlongTrip: JsonField? = null + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var occupancyCapacity: JsonField? = null + private var occupancyCount: JsonField? = null + private var occupancyStatus: JsonField? = null + private var phase: JsonField? = null + private var predicted: JsonField? = null + private var scheduleDeviation: JsonField? = null + private var serviceDate: JsonField? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null + private var closestStopTimeOffset: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var lastKnownLocation: JsonField = JsonMissing.of() + private var lastKnownOrientation: JsonField = JsonMissing.of() + private var nextStop: JsonField = JsonMissing.of() + private var nextStopTimeOffset: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var vehicleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tripStatus: TripStatus) = apply { + activeTripId = tripStatus.activeTripId + blockTripSequence = tripStatus.blockTripSequence + closestStop = tripStatus.closestStop + distanceAlongTrip = tripStatus.distanceAlongTrip + lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip + lastLocationUpdateTime = tripStatus.lastLocationUpdateTime + lastUpdateTime = tripStatus.lastUpdateTime + occupancyCapacity = tripStatus.occupancyCapacity + occupancyCount = tripStatus.occupancyCount + occupancyStatus = tripStatus.occupancyStatus + phase = tripStatus.phase + predicted = tripStatus.predicted + scheduleDeviation = tripStatus.scheduleDeviation + serviceDate = tripStatus.serviceDate + status = tripStatus.status + totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip + closestStopTimeOffset = tripStatus.closestStopTimeOffset + frequency = tripStatus.frequency + lastKnownLocation = tripStatus.lastKnownLocation + lastKnownOrientation = tripStatus.lastKnownOrientation + nextStop = tripStatus.nextStop + nextStopTimeOffset = tripStatus.nextStopTimeOffset + orientation = tripStatus.orientation + position = tripStatus.position + scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip + situationIds = tripStatus.situationIds.map { it.toMutableList() } + vehicleId = tripStatus.vehicleId + additionalProperties = tripStatus.additionalProperties.toMutableMap() + } + + /** Trip ID of the trip the vehicle is actively serving. */ + fun activeTripId(activeTripId: String) = + activeTripId(JsonField.of(activeTripId)) + + /** + * Sets [Builder.activeTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.activeTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun activeTripId(activeTripId: JsonField) = apply { + this.activeTripId = activeTripId + } + + /** Index of the active trip into the sequence of trips for the active block. */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** ID of the closest stop to the current location of the transit vehicle. */ + fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) + + /** + * Sets [Builder.closestStop] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStop(closestStop: JsonField) = apply { + this.closestStop = closestStop + } + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + */ + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = + lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) + + /** + * Sets [Builder.lastKnownDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = + apply { + this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip + } + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + /** Timestamp of the last known real-time update from the transit vehicle. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Capacity of the transit vehicle in terms of occupancy. */ + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + /** Current count of occupants in the transit vehicle. */ + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Current journey phase of the trip. */ + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + */ + fun scheduleDeviation(scheduleDeviation: Long) = + scheduleDeviation(JsonField.of(scheduleDeviation)) + + /** + * Sets [Builder.scheduleDeviation] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDeviation] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduleDeviation(scheduleDeviation: JsonField) = apply { + this.scheduleDeviation = scheduleDeviation + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** Current status modifiers for the trip. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total length of the trip, in meters. */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = + totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) + + /** + * Sets [Builder.totalDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDistanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { + this.totalDistanceAlongTrip = totalDistanceAlongTrip + } + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(closestStopTimeOffset: Long) = + closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) + + /** + * Sets [Builder.closestStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { + this.closestStopTimeOffset = closestStopTimeOffset + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownLocation] with a well-typed + * [LastKnownLocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastKnownLocation(lastKnownLocation: JsonField) = apply { + this.lastKnownLocation = lastKnownLocation + } + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + fun lastKnownOrientation(lastKnownOrientation: Double) = + lastKnownOrientation(JsonField.of(lastKnownOrientation)) + + /** + * Sets [Builder.lastKnownOrientation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownOrientation] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { + this.lastKnownOrientation = lastKnownOrientation + } + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) + + /** + * Sets [Builder.nextStop] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + fun nextStopTimeOffset(nextStopTimeOffset: Long) = + nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) + + /** + * Sets [Builder.nextStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStopTimeOffset] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { + this.nextStopTimeOffset = nextStopTimeOffset + } + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = + scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) + + /** + * Sets [Builder.scheduledDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: kotlin.collections.List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = + apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripStatus = + TripStatus( + checkRequired("activeTripId", activeTripId), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("closestStop", closestStop), + checkRequired("distanceAlongTrip", distanceAlongTrip), + checkRequired("lastKnownDistanceAlongTrip", lastKnownDistanceAlongTrip), + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("occupancyCapacity", occupancyCapacity), + checkRequired("occupancyCount", occupancyCount), + checkRequired("occupancyStatus", occupancyStatus), + checkRequired("phase", phase), + checkRequired("predicted", predicted), + checkRequired("scheduleDeviation", scheduleDeviation), + checkRequired("serviceDate", serviceDate), + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + vehicleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripStatus = apply { + if (validated) { + return@apply + } + + activeTripId() + blockTripSequence() + closestStop() + distanceAlongTrip() + lastKnownDistanceAlongTrip() + lastLocationUpdateTime() + lastUpdateTime() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + predicted() + scheduleDeviation() + serviceDate() + status() + totalDistanceAlongTrip() + closestStopTimeOffset() + frequency() + lastKnownLocation().ifPresent { it.validate() } + lastKnownOrientation() + nextStop() + nextStopTimeOffset() + orientation() + position().ifPresent { it.validate() } + scheduledDistanceAlongTrip() + situationIds() + vehicleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (activeTripId.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (closestStop.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastKnownDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (scheduleDeviation.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (totalDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (closestStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (lastKnownLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastKnownOrientation.asKnown().isPresent) 1 else 0) + + (if (nextStop.asKnown().isPresent) 1 else 0) + + (if (nextStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + + (if (scheduledDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + /** Last known location of the transit vehicle. */ + class LastKnownLocation + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && distanceAlongTrip == other.distanceAlongTrip && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && serviceDate == other.serviceDate && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && closestStopTimeOffset == other.closestStopTimeOffset && frequency == other.frequency && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && orientation == other.orientation && position == other.position && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && situationIds == other.situationIds && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, distanceAlongTrip, lastKnownDistanceAlongTrip, lastLocationUpdateTime, lastUpdateTime, occupancyCapacity, occupancyCount, occupancyStatus, phase, predicted, scheduleDeviation, serviceDate, status, totalDistanceAlongTrip, closestStopTimeOffset, frequency, lastKnownLocation, lastKnownOrientation, nextStop, nextStopTimeOffset, orientation, position, scheduledDistanceAlongTrip, situationIds, vehicleId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && location == other.location && tripId == other.tripId && tripStatus == other.tripStatus && vehicleId == other.vehicleId && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lastLocationUpdateTime, lastUpdateTime, location, tripId, tripStatus, vehicleId, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, location=$location, tripId=$tripId, tripStatus=$tripStatus, vehicleId=$vehicleId, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is VehiclesForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VehiclesForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt index 202311d..3b4ca66 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt @@ -1,23 +1,76 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.AgenciesWithCoverageListParams -import org.onebusaway.models.AgenciesWithCoverageListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse interface AgenciesWithCoverageServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Returns a list of all transit agencies currently supported by OneBusAway along with the * center of their coverage area. */ - @JvmOverloads + fun list(): CompletableFuture = + list(AgenciesWithCoverageListParams.none()) + + /** @see [list] */ fun list( - params: AgenciesWithCoverageListParams, - requestOptions: RequestOptions = RequestOptions.none() + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(AgenciesWithCoverageListParams.none(), requestOptions) + + /** + * A view of [AgenciesWithCoverageServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/agencies-with-coverage.json`, but is + * otherwise the same as [AgenciesWithCoverageServiceAsync.list]. + */ + @MustBeClosed + fun list(): CompletableFuture> = + list(AgenciesWithCoverageListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(AgenciesWithCoverageListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt index 323fc27..ae8826a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,45 +12,60 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.AgenciesWithCoverageListParams -import org.onebusaway.models.AgenciesWithCoverageListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : AgenciesWithCoverageServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCoverageServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AgenciesWithCoverageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): AgenciesWithCoverageServiceAsync.WithRawResponse = + withRawResponse - /** - * Returns a list of all transit agencies currently supported by OneBusAway along with the - * center of their coverage area. - */ override fun list( params: AgenciesWithCoverageListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "agencies-with-coverage.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/agencies-with-coverage.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AgenciesWithCoverageServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AgenciesWithCoverageListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "agencies-with-coverage.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt index 6520228..65fa413 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt @@ -1,20 +1,106 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.AgencyRetrieveParams -import org.onebusaway.models.AgencyRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.agency.AgencyRetrieveParams +import org.onebusaway.models.agency.AgencyRetrieveResponse interface AgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve information for a specific transit agency identified by its unique ID. */ - @JvmOverloads + fun retrieve(agencyId: String): CompletableFuture = + retrieve(agencyId, AgencyRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + ): CompletableFuture = retrieve(agencyId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: AgencyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: AgencyRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(agencyId, AgencyRetrieveParams.none(), requestOptions) + + /** + * A view of [AgencyServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/agency/{agencyID}.json`, but is otherwise + * the same as [AgencyServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(agencyId: String): CompletableFuture> = + retrieve(agencyId, AgencyRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + ): CompletableFuture> = + retrieve(agencyId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AgencyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AgencyRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(agencyId, AgencyRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt index cb99dec..b4ee1be 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt @@ -3,49 +3,73 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.AgencyRetrieveParams -import org.onebusaway.models.AgencyRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : AgencyServiceAsync { +class AgencyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): AgencyServiceAsync.WithRawResponse = withRawResponse - /** Retrieve information for a specific transit agency identified by its unique ID. */ override fun retrieve( params: AgencyRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "agency", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/agency/{agencyID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: AgencyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "agency", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt index 339e502..5d85667 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt @@ -1,29 +1,176 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureListResponse -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListResponse +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveResponse interface ArrivalAndDepartureServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** arrival-and-departure-for-stop */ - @JvmOverloads fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): CompletableFuture = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, params: ArrivalAndDepartureRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + params: ArrivalAndDepartureRetrieveParams + ): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** arrivals-and-departures-for-stop */ - @JvmOverloads + fun list(stopId: String): CompletableFuture = + list(stopId, ArrivalAndDepartureListParams.none()) + + /** @see [list] */ + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [list] */ + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + ): CompletableFuture = + list(stopId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: ArrivalAndDepartureListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: ArrivalAndDepartureListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(stopId, ArrivalAndDepartureListParams.none(), requestOptions) + + /** + * A view of [ArrivalAndDepartureServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get + * /api/where/arrival-and-departure-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ArrivalAndDepartureRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get + * /api/where/arrivals-and-departures-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureServiceAsync.list]. + */ + @MustBeClosed + fun list( + stopId: String + ): CompletableFuture> = + list(stopId, ArrivalAndDepartureListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + ): CompletableFuture> = + list(stopId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: ArrivalAndDepartureListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: ArrivalAndDepartureListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(stopId, ArrivalAndDepartureListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt index 44a3670..bc5c1ea 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt @@ -3,92 +3,126 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureListResponse -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse +import org.onebusaway.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 -constructor( - private val clientOptions: ClientOptions, -) : ArrivalAndDepartureServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepartureServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ArrivalAndDepartureServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ArrivalAndDepartureServiceAsync.WithRawResponse = + withRawResponse - /** arrival-and-departure-for-stop */ override fun retrieve( params: ArrivalAndDepartureRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "arrival-and-departure-for-stop", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + 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(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "arrival-and-departure-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - /** arrivals-and-departures-for-stop */ - override fun list( - params: ArrivalAndDepartureListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "arrivals-and-departures-for-stop", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + override fun list( + params: ArrivalAndDepartureListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "arrivals-and-departures-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt index 8d2afda..543b005 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.BlockRetrieveParams -import org.onebusaway.models.BlockRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.block.BlockRetrieveParams +import org.onebusaway.models.block.BlockRetrieveResponse interface BlockServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific block by ID */ - @JvmOverloads + fun retrieve(blockId: String): CompletableFuture = + retrieve(blockId, BlockRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + ): CompletableFuture = retrieve(blockId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: BlockRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: BlockRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(blockId, BlockRetrieveParams.none(), requestOptions) + + /** A view of [BlockServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/block/{blockID}.json`, but is otherwise + * the same as [BlockServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(blockId: String): CompletableFuture> = + retrieve(blockId, BlockRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + ): CompletableFuture> = + retrieve(blockId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: BlockRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: BlockRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(blockId, BlockRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt index a0f011e..30df072 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt @@ -3,49 +3,73 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.BlockRetrieveParams -import org.onebusaway.models.BlockRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : BlockServiceAsync { +class BlockServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BlockServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: BlockServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): BlockServiceAsync.WithRawResponse = withRawResponse - /** Get details of a specific block by ID */ override fun retrieve( params: BlockRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "block", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/block/{blockID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BlockServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: BlockRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "block", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt index 79530a4..13c3253 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt @@ -1,20 +1,72 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ConfigRetrieveParams -import org.onebusaway.models.ConfigRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.config.ConfigRetrieveParams +import org.onebusaway.models.config.ConfigRetrieveResponse interface ConfigServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** config */ - @JvmOverloads + fun retrieve(): CompletableFuture = + retrieve(ConfigRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: ConfigRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none() + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(requestOptions: RequestOptions): CompletableFuture = + retrieve(ConfigRetrieveParams.none(), requestOptions) + + /** + * A view of [ConfigServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/config.json`, but is otherwise the same + * as [ConfigServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(): CompletableFuture> = + retrieve(ConfigRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none() + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture> = + retrieve(ConfigRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt index 4ab63ba..c575a72 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,41 +12,59 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ConfigRetrieveParams -import org.onebusaway.models.ConfigRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : ConfigServiceAsync { +class ConfigServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ConfigServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ConfigServiceAsync.WithRawResponse = withRawResponse - /** config */ override fun retrieve( params: ConfigRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "config.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/config.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ConfigRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "config.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt index c26d89d..6702fa8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt @@ -1,20 +1,73 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse interface CurrentTimeServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** current-time */ - @JvmOverloads + fun retrieve(): CompletableFuture = + retrieve(CurrentTimeRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: CurrentTimeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none() + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(requestOptions: RequestOptions): CompletableFuture = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) + + /** + * A view of [CurrentTimeServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/current-time.json`, but is otherwise the + * same as [CurrentTimeServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(): CompletableFuture> = + retrieve(CurrentTimeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none() + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture> = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt index fb53cef..c6e7e08 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,42 +12,59 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : CurrentTimeServiceAsync { +class CurrentTimeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CurrentTimeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): CurrentTimeServiceAsync.WithRawResponse = withRawResponse - /** current-time */ override fun retrieve( params: CurrentTimeRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "current-time.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/current-time.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: CurrentTimeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "current-time.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt index 718bef1..9c5fadc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt @@ -1,20 +1,108 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ReportProblemWithStopRetrieveParams +import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams interface ReportProblemWithStopServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Submit a user-generated problem report for a stop */ - @JvmOverloads + fun retrieve(stopId: String): CompletableFuture = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + ): CompletableFuture = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ReportProblemWithStopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: ReportProblemWithStopRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none(), requestOptions) + + /** + * A view of [ReportProblemWithStopServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-stop/{stopID}.json`, + * but is otherwise the same as [ReportProblemWithStopServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): CompletableFuture> = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = + ReportProblemWithStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithStopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithStopRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt index d1fdd21..ff5765e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt @@ -3,54 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ReportProblemWithStopRetrieveParams +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 -constructor( - private val clientOptions: ClientOptions, -) : ReportProblemWithStopServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithStopServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ReportProblemWithStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ReportProblemWithStopServiceAsync.WithRawResponse = + withRawResponse - /** Submit a user-generated problem report for a stop */ override fun retrieve( params: ReportProblemWithStopRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "report-problem-with-stop", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/report-problem-with-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ReportProblemWithStopServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ReportProblemWithStopRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "report-problem-with-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt index 851e7d1..4ed86c7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt @@ -1,20 +1,108 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ReportProblemWithTripRetrieveParams +import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams interface ReportProblemWithTripServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Submit a user-generated problem report for a particular trip. */ - @JvmOverloads + fun retrieve(tripId: String): CompletableFuture = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + ): CompletableFuture = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ReportProblemWithTripRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: ReportProblemWithTripRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none(), requestOptions) + + /** + * A view of [ReportProblemWithTripServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-trip/{tripID}.json`, + * but is otherwise the same as [ReportProblemWithTripServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): CompletableFuture> = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = + ReportProblemWithTripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + ): CompletableFuture> = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithTripRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithTripRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt index a9684b4..c3f940e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt @@ -3,54 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ReportProblemWithTripRetrieveParams +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 -constructor( - private val clientOptions: ClientOptions, -) : ReportProblemWithTripServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithTripServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ReportProblemWithTripServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ReportProblemWithTripServiceAsync.WithRawResponse = + withRawResponse - /** Submit a user-generated problem report for a particular trip. */ override fun retrieve( params: ReportProblemWithTripRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "report-problem-with-trip", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/report-problem-with-trip/{tripID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ReportProblemWithTripServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ReportProblemWithTripRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "report-problem-with-trip", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt index e42ee2c..af5ad86 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RouteIdsForAgencyListParams -import org.onebusaway.models.RouteIdsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListResponse interface RouteIdsForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get route IDs for a specific agency */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, RouteIdsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + ): CompletableFuture = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RouteIdsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: RouteIdsForAgencyListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, RouteIdsForAgencyListParams.none(), requestOptions) + + /** + * A view of [RouteIdsForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/route-ids-for-agency/{agencyID}.json`, + * but is otherwise the same as [RouteIdsForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list( + agencyId: String + ): CompletableFuture> = + list(agencyId, RouteIdsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RouteIdsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: RouteIdsForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, RouteIdsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt index 946e9e5..7040fa2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.RouteIdsForAgencyListParams -import org.onebusaway.models.RouteIdsForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : RouteIdsForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : RouteIdsForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RouteIdsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RouteIdsForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Get route IDs for a specific agency */ override fun list( params: RouteIdsForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "route-ids-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/route-ids-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RouteIdsForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RouteIdsForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "route-ids-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt index d13343c..96edd41 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RouteRetrieveParams -import org.onebusaway.models.RouteRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.route.RouteRetrieveParams +import org.onebusaway.models.route.RouteRetrieveResponse interface RouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve information for a specific route identified by its unique ID. */ - @JvmOverloads + fun retrieve(routeId: String): CompletableFuture = + retrieve(routeId, RouteRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + ): CompletableFuture = retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: RouteRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: RouteRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(routeId, RouteRetrieveParams.none(), requestOptions) + + /** A view of [RouteServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/route/{routeID}.json`, but is otherwise + * the same as [RouteServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(routeId: String): CompletableFuture> = + retrieve(routeId, RouteRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + ): CompletableFuture> = + retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: RouteRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: RouteRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(routeId, RouteRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt index 2053d9f..fa3f4c6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt @@ -3,49 +3,73 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.RouteRetrieveParams -import org.onebusaway.models.RouteRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : RouteServiceAsync { +class RouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): RouteServiceAsync.WithRawResponse = withRawResponse - /** Retrieve information for a specific route identified by its unique ID. */ override fun retrieve( params: RouteRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "route", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/route/{routeID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: RouteRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "route", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt index 91ad8aa..579e603 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt @@ -1,20 +1,110 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RoutesForAgencyListParams -import org.onebusaway.models.RoutesForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse interface RoutesForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve the list of all routes for a particular agency by id */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, RoutesForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + ): CompletableFuture = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RoutesForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: RoutesForAgencyListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, RoutesForAgencyListParams.none(), requestOptions) + + /** + * A view of [RoutesForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-agency/{agencyID}.json`, but + * is otherwise the same as [RoutesForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list( + agencyId: String + ): CompletableFuture> = + list(agencyId, RoutesForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, RoutesForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt index be8954a..8401bec 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.RoutesForAgencyListParams -import org.onebusaway.models.RoutesForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : RoutesForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : RoutesForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoutesForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RoutesForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Retrieve the list of all routes for a particular agency by id */ override fun list( params: RoutesForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "routes-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/routes-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoutesForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "routes-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt index daad3e3..3be0354 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt @@ -1,20 +1,53 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RoutesForLocationListParams -import org.onebusaway.models.RoutesForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse interface RoutesForLocationServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** routes-for-location */ - @JvmOverloads + fun list( + params: RoutesForLocationListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RoutesForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [RoutesForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-location.json`, but is + * otherwise the same as [RoutesForLocationServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: RoutesForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt index 3da5cf6..4208b4d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,42 +12,59 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.RoutesForLocationListParams -import org.onebusaway.models.RoutesForLocationListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : RoutesForLocationServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : RoutesForLocationServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoutesForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RoutesForLocationServiceAsync.WithRawResponse = withRawResponse - /** routes-for-location */ override fun list( params: RoutesForLocationListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "routes-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/routes-for-location.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForLocationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "routes-for-location.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt index 2bd92f9..adf72f3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ScheduleForRouteRetrieveParams -import org.onebusaway.models.ScheduleForRouteRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse interface ScheduleForRouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve the full schedule for a route on a particular day */ - @JvmOverloads + fun retrieve(routeId: String): CompletableFuture = + retrieve(routeId, ScheduleForRouteRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + ): CompletableFuture = + retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ScheduleForRouteRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: ScheduleForRouteRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(routeId, ScheduleForRouteRetrieveParams.none(), requestOptions) + + /** + * A view of [ScheduleForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-route/{routeID}.json`, but + * is otherwise the same as [ScheduleForRouteServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + routeId: String + ): CompletableFuture> = + retrieve(routeId, ScheduleForRouteRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + ): CompletableFuture> = + retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForRouteRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForRouteRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(routeId, ScheduleForRouteRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt index 4d0fed3..e2d9e81 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ScheduleForRouteRetrieveParams -import org.onebusaway.models.ScheduleForRouteRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : ScheduleForRouteServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ScheduleForRouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ScheduleForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ScheduleForRouteServiceAsync.WithRawResponse = withRawResponse - /** Retrieve the full schedule for a route on a particular day */ override fun retrieve( params: ScheduleForRouteRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "schedule-for-route", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/schedule-for-route/{routeID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForRouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ScheduleForRouteRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "schedule-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt index d553c5c..886f4a1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ScheduleForStopRetrieveParams -import org.onebusaway.models.ScheduleForStopRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveResponse interface ScheduleForStopServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get schedule for a specific stop */ - @JvmOverloads + fun retrieve(stopId: String): CompletableFuture = + retrieve(stopId, ScheduleForStopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + ): CompletableFuture = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ScheduleForStopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: ScheduleForStopRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(stopId, ScheduleForStopRetrieveParams.none(), requestOptions) + + /** + * A view of [ScheduleForStopServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-stop/{stopID}.json`, but is + * otherwise the same as [ScheduleForStopServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + stopId: String + ): CompletableFuture> = + retrieve(stopId, ScheduleForStopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForStopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForStopRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(stopId, ScheduleForStopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt index 5b4b0f3..96f3b3d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ScheduleForStopRetrieveParams -import org.onebusaway.models.ScheduleForStopRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : ScheduleForStopServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ScheduleForStopServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ScheduleForStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ScheduleForStopServiceAsync.WithRawResponse = withRawResponse - /** Get schedule for a specific stop */ override fun retrieve( params: ScheduleForStopRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "schedule-for-stop", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/schedule-for-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForStopServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ScheduleForStopRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "schedule-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt index d63a5d4..ea62172 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.SearchForRouteListParams -import org.onebusaway.models.SearchForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.searchforroute.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListResponse interface SearchForRouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for a route based on its name. */ - @JvmOverloads + fun list(params: SearchForRouteListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: SearchForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [SearchForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/search/route.json`, but is otherwise the + * same as [SearchForRouteServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: SearchForRouteListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt index 0dd6fb7..574b9ee 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,42 +12,59 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.SearchForRouteListParams -import org.onebusaway.models.SearchForRouteListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : SearchForRouteServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : SearchForRouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SearchForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SearchForRouteServiceAsync.WithRawResponse = withRawResponse - /** Search for a route based on its name. */ override fun list( params: SearchForRouteListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "search", "route.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/search/route.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForRouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "search", "route.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt index 31d27f4..525689c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.SearchForStopListParams -import org.onebusaway.models.SearchForStopListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.searchforstop.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListResponse interface SearchForStopServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for a stop based on its name. */ - @JvmOverloads + fun list(params: SearchForStopListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: SearchForStopListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [SearchForStopServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/search/stop.json`, but is otherwise the + * same as [SearchForStopServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: SearchForStopListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt index e644aa3..51078e2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,42 +12,59 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.SearchForStopListParams -import org.onebusaway.models.SearchForStopListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : SearchForStopServiceAsync { +class SearchForStopServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SearchForStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SearchForStopServiceAsync.WithRawResponse = withRawResponse - /** Search for a stop based on its name. */ override fun list( params: SearchForStopListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "search", "stop.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/search/stop.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "search", "stop.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt index ba76e9a..4614a08 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ShapeRetrieveParams -import org.onebusaway.models.ShapeRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.shape.ShapeRetrieveParams +import org.onebusaway.models.shape.ShapeRetrieveResponse interface ShapeServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ - @JvmOverloads + fun retrieve(shapeId: String): CompletableFuture = + retrieve(shapeId, ShapeRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + ): CompletableFuture = retrieve(shapeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ShapeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: ShapeRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(shapeId, ShapeRetrieveParams.none(), requestOptions) + + /** A view of [ShapeServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/shape/{shapeID}.json`, but is otherwise + * the same as [ShapeServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(shapeId: String): CompletableFuture> = + retrieve(shapeId, ShapeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + ): CompletableFuture> = + retrieve(shapeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ShapeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ShapeRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(shapeId, ShapeRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt index 456938b..17d585e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt @@ -3,49 +3,73 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ShapeRetrieveParams -import org.onebusaway.models.ShapeRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : ShapeServiceAsync { +class ShapeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ShapeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ShapeServiceAsync.WithRawResponse = withRawResponse - /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ override fun retrieve( params: ShapeRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "shape", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/shape/{shapeID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ShapeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shapeId", params.shapeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "shape", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt index 5302c4f..6a2c5f9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt @@ -1,20 +1,110 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopIdsForAgencyListParams -import org.onebusaway.models.StopIdsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse interface StopIdsForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stop IDs for a specific agency */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, StopIdsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + ): CompletableFuture = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopIdsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: StopIdsForAgencyListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, StopIdsForAgencyListParams.none(), requestOptions) + + /** + * A view of [StopIdsForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stop-ids-for-agency/{agencyID}.json`, but + * is otherwise the same as [StopIdsForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list( + agencyId: String + ): CompletableFuture> = + list(agencyId, StopIdsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopIdsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopIdsForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, StopIdsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt index 80f9fe1..bbe0917 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopIdsForAgencyListParams -import org.onebusaway.models.StopIdsForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopIdsForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : StopIdsForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopIdsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopIdsForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Get stop IDs for a specific agency */ override fun list( params: StopIdsForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stop-ids-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stop-ids-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopIdsForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopIdsForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stop-ids-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt index 477416b..597b17d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopRetrieveParams -import org.onebusaway.models.StopRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stop.StopRetrieveParams +import org.onebusaway.models.stop.StopRetrieveResponse interface StopServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific stop */ - @JvmOverloads + fun retrieve(stopId: String): CompletableFuture = + retrieve(stopId, StopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + ): CompletableFuture = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: StopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: StopRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(stopId, StopRetrieveParams.none(), requestOptions) + + /** A view of [StopServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stop/{stopID}.json`, but is otherwise the + * same as [StopServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): CompletableFuture> = + retrieve(stopId, StopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: StopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: StopRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(stopId, StopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt index 134682e..81d7c5a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt @@ -3,49 +3,73 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopRetrieveParams -import org.onebusaway.models.StopRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopServiceAsync { +class StopServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + StopServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): StopServiceAsync.WithRawResponse = withRawResponse - /** Get details of a specific stop */ override fun retrieve( params: StopRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "stop", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: StopRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "stop", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt index a8aa840..af0198f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt @@ -1,20 +1,107 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForAgencyListParams -import org.onebusaway.models.StopsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforagency.StopsForAgencyListParams +import org.onebusaway.models.stopsforagency.StopsForAgencyListResponse interface StopsForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stops for a specific agency */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, StopsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + ): CompletableFuture = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: StopsForAgencyListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, StopsForAgencyListParams.none(), requestOptions) + + /** + * A view of [StopsForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-agency/{agencyID}.json`, but is + * otherwise the same as [StopsForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list(agencyId: String): CompletableFuture> = + list(agencyId, StopsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, StopsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt index e77c0d7..08a34be 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForAgencyListParams -import org.onebusaway.models.StopsForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopsForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : StopsForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Get stops for a specific agency */ override fun list( params: StopsForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stops-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stops-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stops-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt index 18f1776..764ff9a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForLocationListParams -import org.onebusaway.models.StopsForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse interface StopsForLocationServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** stops-for-location */ - @JvmOverloads + fun list(params: StopsForLocationListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [StopsForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-location.json`, but is + * otherwise the same as [StopsForLocationServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: StopsForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt index e646761..586b618 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,42 +12,59 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForLocationListParams -import org.onebusaway.models.StopsForLocationListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopsForLocationServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : StopsForLocationServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForLocationServiceAsync.WithRawResponse = withRawResponse - /** stops-for-location */ override fun list( params: StopsForLocationListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "stops-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stops-for-location.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForLocationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "stops-for-location.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt index 21a4d17..59f7969 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt @@ -1,20 +1,107 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForRouteListParams -import org.onebusaway.models.StopsForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforroute.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse interface StopsForRouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stops for a specific route */ - @JvmOverloads + fun list(routeId: String): CompletableFuture = + list(routeId, StopsForRouteListParams.none()) + + /** @see [list] */ + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + ): CompletableFuture = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: StopsForRouteListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(routeId, StopsForRouteListParams.none(), requestOptions) + + /** + * A view of [StopsForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-route/{routeID}.json`, but is + * otherwise the same as [StopsForRouteServiceAsync.list]. + */ + @MustBeClosed + fun list(routeId: String): CompletableFuture> = + list(routeId, StopsForRouteListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + ): CompletableFuture> = + list(routeId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForRouteListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(routeId, StopsForRouteListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt index f65a3d9..4739e7d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForRouteListParams -import org.onebusaway.models.StopsForRouteListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopsForRouteServiceAsync { +class StopsForRouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForRouteServiceAsync.WithRawResponse = withRawResponse - /** Get stops for a specific route */ override fun list( params: StopsForRouteListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stops-for-route", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stops-for-route/{routeID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForRouteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stops-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt index 9ba625f..5de78ae 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt @@ -1,20 +1,110 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripDetailRetrieveParams -import org.onebusaway.models.TripDetailRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse interface TripDetailServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve Trip Details */ - @JvmOverloads + fun retrieve(tripId: String): CompletableFuture = + retrieve(tripId, TripDetailRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + ): CompletableFuture = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripDetailRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: TripDetailRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(tripId, TripDetailRetrieveParams.none(), requestOptions) + + /** + * A view of [TripDetailServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip-details/{tripID}.json`, but is + * otherwise the same as [TripDetailServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + tripId: String + ): CompletableFuture> = + retrieve(tripId, TripDetailRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + ): CompletableFuture> = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripDetailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripDetailRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(tripId, TripDetailRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt index 653962f..95045d3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt @@ -3,50 +3,73 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripDetailRetrieveParams -import org.onebusaway.models.TripDetailRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripDetailServiceAsync { +class TripDetailServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripDetailServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripDetailServiceAsync.WithRawResponse = withRawResponse - /** Retrieve Trip Details */ override fun retrieve( params: TripDetailRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trip-details", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trip-details/{tripID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripDetailRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trip-details", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt index c5cccd9..3446b32 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripForVehicleRetrieveParams -import org.onebusaway.models.TripForVehicleRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse interface TripForVehicleServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve trip for a specific vehicle */ - @JvmOverloads + fun retrieve(vehicleId: String): CompletableFuture = + retrieve(vehicleId, TripForVehicleRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + ): CompletableFuture = + retrieve(vehicleId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripForVehicleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: TripForVehicleRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(vehicleId, TripForVehicleRetrieveParams.none(), requestOptions) + + /** + * A view of [TripForVehicleServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip-for-vehicle/{vehicleID}.json`, but + * is otherwise the same as [TripForVehicleServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + vehicleId: String + ): CompletableFuture> = + retrieve(vehicleId, TripForVehicleRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + ): CompletableFuture> = + retrieve(vehicleId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripForVehicleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripForVehicleRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(vehicleId, TripForVehicleRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt index 222c4ce..4307268 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripForVehicleRetrieveParams -import org.onebusaway.models.TripForVehicleRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripForVehicleServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : TripForVehicleServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripForVehicleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripForVehicleServiceAsync.WithRawResponse = withRawResponse - /** Retrieve trip for a specific vehicle */ override fun retrieve( params: TripForVehicleRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "trip-for-vehicle", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trip-for-vehicle/{vehicleID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripForVehicleServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripForVehicleRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("vehicleId", params.vehicleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "trip-for-vehicle", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt index f6695da..e137c1a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripRetrieveParams -import org.onebusaway.models.TripRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.trip.TripRetrieveParams +import org.onebusaway.models.trip.TripRetrieveResponse interface TripServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific trip */ - @JvmOverloads + fun retrieve(tripId: String): CompletableFuture = + retrieve(tripId, TripRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + ): CompletableFuture = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: TripRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(tripId, TripRetrieveParams.none(), requestOptions) + + /** A view of [TripServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip/{tripID}.json`, but is otherwise the + * same as [TripServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): CompletableFuture> = + retrieve(tripId, TripRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + ): CompletableFuture> = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(tripId, TripRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt index 784b015..428e431 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt @@ -3,49 +3,73 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripRetrieveParams -import org.onebusaway.models.TripRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripServiceAsync { +class TripServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): TripServiceAsync.WithRawResponse = withRawResponse - /** Get details of a specific trip */ override fun retrieve( params: TripRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trip", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trip/{tripID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trip", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt index 5d82f61..0290143 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripsForLocationListParams -import org.onebusaway.models.TripsForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListResponse interface TripsForLocationServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve trips for a given location */ - @JvmOverloads + fun list(params: TripsForLocationListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: TripsForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [TripsForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-location.json`, but is + * otherwise the same as [TripsForLocationServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: TripsForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt index d4eb6e1..472f2c2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,42 +12,59 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripsForLocationListParams -import org.onebusaway.models.TripsForLocationListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripsForLocationServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : TripsForLocationServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripsForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripsForLocationServiceAsync.WithRawResponse = withRawResponse - /** Retrieve trips for a given location */ override fun list( params: TripsForLocationListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trips-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trips-for-location.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForLocationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trips-for-location.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt index 5f8f848..b9b2161 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt @@ -1,20 +1,107 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripsForRouteListParams -import org.onebusaway.models.TripsForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripsforroute.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse interface TripsForRouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for active trips for a specific route. */ - @JvmOverloads + fun list(routeId: String): CompletableFuture = + list(routeId, TripsForRouteListParams.none()) + + /** @see [list] */ + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + ): CompletableFuture = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: TripsForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: TripsForRouteListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(routeId, TripsForRouteListParams.none(), requestOptions) + + /** + * A view of [TripsForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-route/{routeID}.json`, but is + * otherwise the same as [TripsForRouteServiceAsync.list]. + */ + @MustBeClosed + fun list(routeId: String): CompletableFuture> = + list(routeId, TripsForRouteListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + ): CompletableFuture> = + list(routeId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForRouteListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(routeId, TripsForRouteListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt index 0ab7488..11c93c2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripsForRouteListParams -import org.onebusaway.models.TripsForRouteListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripsForRouteServiceAsync { +class TripsForRouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripsForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripsForRouteServiceAsync.WithRawResponse = withRawResponse - /** Search for active trips for a specific route. */ override fun list( params: TripsForRouteListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "trips-for-route", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trips-for-route/{routeID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TripsForRouteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "trips-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt index f24836a..78aed5c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.VehiclesForAgencyListParams -import org.onebusaway.models.VehiclesForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse interface VehiclesForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get vehicles for a specific agency */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, VehiclesForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + ): CompletableFuture = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: VehiclesForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: VehiclesForAgencyListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, VehiclesForAgencyListParams.none(), requestOptions) + + /** + * A view of [VehiclesForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/vehicles-for-agency/{agencyID}.json`, but + * is otherwise the same as [VehiclesForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list( + agencyId: String + ): CompletableFuture> = + list(agencyId, VehiclesForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: VehiclesForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: VehiclesForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, VehiclesForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt index 81658bb..aa2e990 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt @@ -3,55 +3,78 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.VehiclesForAgencyListParams -import org.onebusaway.models.VehiclesForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : VehiclesForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : VehiclesForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: VehiclesForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): VehiclesForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Get vehicles for a specific agency */ override fun list( params: VehiclesForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "vehicles-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/vehicles-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VehiclesForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: VehiclesForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "vehicles-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt index 8e54c10..1f18b1c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt @@ -1,22 +1,73 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.AgenciesWithCoverageListParams -import org.onebusaway.models.AgenciesWithCoverageListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse interface AgenciesWithCoverageService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Returns a list of all transit agencies currently supported by OneBusAway along with the * center of their coverage area. */ - @JvmOverloads + fun list(): AgenciesWithCoverageListResponse = list(AgenciesWithCoverageListParams.none()) + + /** @see [list] */ fun list( - params: AgenciesWithCoverageListParams, - requestOptions: RequestOptions = RequestOptions.none() + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): AgenciesWithCoverageListResponse + + /** @see [list] */ + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none() + ): AgenciesWithCoverageListResponse = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(requestOptions: RequestOptions): AgenciesWithCoverageListResponse = + list(AgenciesWithCoverageListParams.none(), requestOptions) + + /** + * A view of [AgenciesWithCoverageService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/agencies-with-coverage.json`, but is + * otherwise the same as [AgenciesWithCoverageService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = + list(AgenciesWithCoverageListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): HttpResponseFor = + list(AgenciesWithCoverageListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt index 1c8cfeb..a109b92 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,46 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.AgenciesWithCoverageListParams -import org.onebusaway.models.AgenciesWithCoverageListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : AgenciesWithCoverageService { +internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCoverageService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AgenciesWithCoverageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): AgenciesWithCoverageService.WithRawResponse = withRawResponse - /** - * Returns a list of all transit agencies currently supported by OneBusAway along with the - * center of their coverage area. - */ override fun list( params: AgenciesWithCoverageListParams, - requestOptions: RequestOptions - ): AgenciesWithCoverageListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "agencies-with-coverage.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): AgenciesWithCoverageListResponse = + // get /api/where/agencies-with-coverage.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AgenciesWithCoverageService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AgenciesWithCoverageListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "agencies-with-coverage.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt index 33676cb..2d98f44 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt @@ -1,19 +1,98 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.AgencyRetrieveParams -import org.onebusaway.models.AgencyRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.agency.AgencyRetrieveParams +import org.onebusaway.models.agency.AgencyRetrieveResponse interface AgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve information for a specific transit agency identified by its unique ID. */ - @JvmOverloads + fun retrieve(agencyId: String): AgencyRetrieveResponse = + retrieve(agencyId, AgencyRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AgencyRetrieveResponse = + retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + ): AgencyRetrieveResponse = retrieve(agencyId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: AgencyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AgencyRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: AgencyRetrieveParams): AgencyRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(agencyId: String, requestOptions: RequestOptions): AgencyRetrieveResponse = + retrieve(agencyId, AgencyRetrieveParams.none(), requestOptions) + + /** A view of [AgencyService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/agency/{agencyID}.json`, but is otherwise + * the same as [AgencyService.retrieve]. + */ + @MustBeClosed + fun retrieve(agencyId: String): HttpResponseFor = + retrieve(agencyId, AgencyRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + ): HttpResponseFor = + retrieve(agencyId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AgencyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: AgencyRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(agencyId, AgencyRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt index c39bf09..e8e2b39 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt @@ -2,50 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.AgencyRetrieveParams -import org.onebusaway.models.AgencyRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : AgencyService { +class AgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): AgencyService.WithRawResponse = withRawResponse - /** Retrieve information for a specific transit agency identified by its unique ID. */ override fun retrieve( params: AgencyRetrieveParams, - requestOptions: RequestOptions - ): AgencyRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "agency", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): AgencyRetrieveResponse = + // get /api/where/agency/{agencyID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: AgencyRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "agency", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt index deb29be..0638304 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt @@ -1,28 +1,164 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureListResponse -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListResponse +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveResponse interface ArrivalAndDepartureService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** arrival-and-departure-for-stop */ - @JvmOverloads + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): ArrivalAndDepartureRetrieveResponse = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ArrivalAndDepartureRetrieveResponse = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve(params: ArrivalAndDepartureRetrieveParams): ArrivalAndDepartureRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ArrivalAndDepartureRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ArrivalAndDepartureRetrieveResponse /** arrivals-and-departures-for-stop */ - @JvmOverloads + fun list(stopId: String): ArrivalAndDepartureListResponse = + list(stopId, ArrivalAndDepartureListParams.none()) + + /** @see [list] */ + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ArrivalAndDepartureListResponse = + list(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [list] */ + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + ): ArrivalAndDepartureListResponse = list(stopId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: ArrivalAndDepartureListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ArrivalAndDepartureListResponse + + /** @see [list] */ + fun list(params: ArrivalAndDepartureListParams): ArrivalAndDepartureListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(stopId: String, requestOptions: RequestOptions): ArrivalAndDepartureListResponse = + list(stopId, ArrivalAndDepartureListParams.none(), requestOptions) + + /** + * A view of [ArrivalAndDepartureService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get + * /api/where/arrival-and-departure-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureService.retrieve]. + */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): HttpResponseFor = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ArrivalAndDepartureRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get + * /api/where/arrivals-and-departures-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureService.list]. + */ + @MustBeClosed + fun list(stopId: String): HttpResponseFor = + list(stopId, ArrivalAndDepartureListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + ): HttpResponseFor = + list(stopId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: ArrivalAndDepartureListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: ArrivalAndDepartureListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(stopId, ArrivalAndDepartureListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt index aa760e4..cee01ad 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt @@ -2,92 +2,121 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureListResponse -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse +import org.onebusaway.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 -constructor( - private val clientOptions: ClientOptions, -) : ArrivalAndDepartureService { +internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepartureService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ArrivalAndDepartureService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ArrivalAndDepartureService.WithRawResponse = withRawResponse - /** arrival-and-departure-for-stop */ override fun retrieve( params: ArrivalAndDepartureRetrieveParams, - requestOptions: RequestOptions - ): ArrivalAndDepartureRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "arrival-and-departure-for-stop", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + 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(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "arrival-and-departure-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } - } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - /** arrivals-and-departures-for-stop */ - override fun list( - params: ArrivalAndDepartureListParams, - requestOptions: RequestOptions - ): ArrivalAndDepartureListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "arrivals-and-departures-for-stop", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + override fun list( + params: ArrivalAndDepartureListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "arrivals-and-departures-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt index 850f9e3..0508966 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt @@ -1,19 +1,96 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.BlockRetrieveParams -import org.onebusaway.models.BlockRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.block.BlockRetrieveParams +import org.onebusaway.models.block.BlockRetrieveResponse interface BlockService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific block by ID */ - @JvmOverloads + fun retrieve(blockId: String): BlockRetrieveResponse = + retrieve(blockId, BlockRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BlockRetrieveResponse = retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + ): BlockRetrieveResponse = retrieve(blockId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: BlockRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): BlockRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: BlockRetrieveParams): BlockRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(blockId: String, requestOptions: RequestOptions): BlockRetrieveResponse = + retrieve(blockId, BlockRetrieveParams.none(), requestOptions) + + /** A view of [BlockService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/block/{blockID}.json`, but is otherwise + * the same as [BlockService.retrieve]. + */ + @MustBeClosed + fun retrieve(blockId: String): HttpResponseFor = + retrieve(blockId, BlockRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + ): HttpResponseFor = retrieve(blockId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: BlockRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: BlockRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(blockId, BlockRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt index c540ec2..04ec198 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt @@ -2,50 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.BlockRetrieveParams -import org.onebusaway.models.BlockRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : BlockService { +class BlockServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BlockService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: BlockService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): BlockService.WithRawResponse = withRawResponse - /** Get details of a specific block by ID */ override fun retrieve( params: BlockRetrieveParams, - requestOptions: RequestOptions - ): BlockRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "block", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): BlockRetrieveResponse = + // get /api/where/block/{blockID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BlockService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: BlockRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "block", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt index b28fab8..fdce05f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt @@ -1,19 +1,65 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ConfigRetrieveParams -import org.onebusaway.models.ConfigRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.config.ConfigRetrieveParams +import org.onebusaway.models.config.ConfigRetrieveResponse interface ConfigService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** config */ - @JvmOverloads + fun retrieve(): ConfigRetrieveResponse = retrieve(ConfigRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: ConfigRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): ConfigRetrieveResponse + + /** @see [retrieve] */ + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none() + ): ConfigRetrieveResponse = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(requestOptions: RequestOptions): ConfigRetrieveResponse = + retrieve(ConfigRetrieveParams.none(), requestOptions) + + /** A view of [ConfigService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/config.json`, but is otherwise the same + * as [ConfigService.retrieve]. + */ + @MustBeClosed + fun retrieve(): HttpResponseFor = + retrieve(ConfigRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none() + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(requestOptions: RequestOptions): HttpResponseFor = + retrieve(ConfigRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt index 574e7b2..e4e752b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,42 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ConfigRetrieveParams -import org.onebusaway.models.ConfigRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : ConfigService { +class ConfigServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ConfigService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ConfigService.WithRawResponse = withRawResponse - /** config */ override fun retrieve( params: ConfigRetrieveParams, - requestOptions: RequestOptions - ): ConfigRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "config.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): ConfigRetrieveResponse = + // get /api/where/config.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ConfigRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "config.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt index 95d6a7c..2d912a3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt @@ -1,19 +1,67 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse interface CurrentTimeService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** current-time */ - @JvmOverloads + fun retrieve(): CurrentTimeRetrieveResponse = retrieve(CurrentTimeRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: CurrentTimeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CurrentTimeRetrieveResponse + + /** @see [retrieve] */ + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none() + ): CurrentTimeRetrieveResponse = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(requestOptions: RequestOptions): CurrentTimeRetrieveResponse = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) + + /** + * A view of [CurrentTimeService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/current-time.json`, but is otherwise the + * same as [CurrentTimeService.retrieve]. + */ + @MustBeClosed + fun retrieve(): HttpResponseFor = + retrieve(CurrentTimeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none() + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(requestOptions: RequestOptions): HttpResponseFor = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt index b5abf2f..ee69013 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,43 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : CurrentTimeService { +class CurrentTimeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CurrentTimeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): CurrentTimeService.WithRawResponse = withRawResponse - /** current-time */ override fun retrieve( params: CurrentTimeRetrieveParams, - requestOptions: RequestOptions - ): CurrentTimeRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "current-time.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CurrentTimeRetrieveResponse = + // get /api/where/current-time.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: CurrentTimeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "current-time.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt index 1085081..2869322 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt @@ -1,19 +1,101 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ReportProblemWithStopRetrieveParams +import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams interface ReportProblemWithStopService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Submit a user-generated problem report for a stop */ - @JvmOverloads + fun retrieve(stopId: String): ResponseWrapper = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseWrapper = retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + ): ResponseWrapper = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ReportProblemWithStopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ResponseWrapper + + /** @see [retrieve] */ + fun retrieve(params: ReportProblemWithStopRetrieveParams): ResponseWrapper = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(stopId: String, requestOptions: RequestOptions): ResponseWrapper = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none(), requestOptions) + + /** + * A view of [ReportProblemWithStopService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-stop/{stopID}.json`, + * but is otherwise the same as [ReportProblemWithStopService.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): HttpResponseFor = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = + ReportProblemWithStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + ): HttpResponseFor = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithStopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithStopRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt index fc36bc6..91a98bc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt @@ -2,55 +2,76 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ReportProblemWithStopRetrieveParams +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 -constructor( - private val clientOptions: ClientOptions, -) : ReportProblemWithStopService { +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithStopService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ReportProblemWithStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ReportProblemWithStopService.WithRawResponse = withRawResponse - /** Submit a user-generated problem report for a stop */ override fun retrieve( params: ReportProblemWithStopRetrieveParams, - requestOptions: RequestOptions - ): ResponseWrapper { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "report-problem-with-stop", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): ResponseWrapper = + // get /api/where/report-problem-with-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ReportProblemWithStopService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ReportProblemWithStopRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "report-problem-with-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt index d8e2a3d..db963a6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt @@ -1,19 +1,101 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ReportProblemWithTripRetrieveParams +import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams interface ReportProblemWithTripService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Submit a user-generated problem report for a particular trip. */ - @JvmOverloads + fun retrieve(tripId: String): ResponseWrapper = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseWrapper = retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + ): ResponseWrapper = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ReportProblemWithTripRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ResponseWrapper + + /** @see [retrieve] */ + fun retrieve(params: ReportProblemWithTripRetrieveParams): ResponseWrapper = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(tripId: String, requestOptions: RequestOptions): ResponseWrapper = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none(), requestOptions) + + /** + * A view of [ReportProblemWithTripService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-trip/{tripID}.json`, + * but is otherwise the same as [ReportProblemWithTripService.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): HttpResponseFor = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = + ReportProblemWithTripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + ): HttpResponseFor = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithTripRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithTripRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt index e6b700e..48e57de 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt @@ -2,55 +2,76 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ReportProblemWithTripRetrieveParams +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 -constructor( - private val clientOptions: ClientOptions, -) : ReportProblemWithTripService { +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithTripService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ReportProblemWithTripService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ReportProblemWithTripService.WithRawResponse = withRawResponse - /** Submit a user-generated problem report for a particular trip. */ override fun retrieve( params: ReportProblemWithTripRetrieveParams, - requestOptions: RequestOptions - ): ResponseWrapper { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "report-problem-with-trip", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): ResponseWrapper = + // get /api/where/report-problem-with-trip/{tripID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ReportProblemWithTripService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ReportProblemWithTripRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "report-problem-with-trip", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt index 6cd5d26..5709b20 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt @@ -1,19 +1,102 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RouteIdsForAgencyListParams -import org.onebusaway.models.RouteIdsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListResponse interface RouteIdsForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get route IDs for a specific agency */ - @JvmOverloads + fun list(agencyId: String): RouteIdsForAgencyListResponse = + list(agencyId, RouteIdsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RouteIdsForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + ): RouteIdsForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RouteIdsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RouteIdsForAgencyListResponse + + /** @see [list] */ + fun list(params: RouteIdsForAgencyListParams): RouteIdsForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): RouteIdsForAgencyListResponse = + list(agencyId, RouteIdsForAgencyListParams.none(), requestOptions) + + /** + * A view of [RouteIdsForAgencyService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/route-ids-for-agency/{agencyID}.json`, + * but is otherwise the same as [RouteIdsForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, RouteIdsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RouteIdsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: RouteIdsForAgencyListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, RouteIdsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt index b6f67da..44ef629 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.RouteIdsForAgencyListParams -import org.onebusaway.models.RouteIdsForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : RouteIdsForAgencyService { +class RouteIdsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RouteIdsForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RouteIdsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RouteIdsForAgencyService.WithRawResponse = withRawResponse - /** Get route IDs for a specific agency */ override fun list( params: RouteIdsForAgencyListParams, - requestOptions: RequestOptions - ): RouteIdsForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "route-ids-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): RouteIdsForAgencyListResponse = + // get /api/where/route-ids-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RouteIdsForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RouteIdsForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "route-ids-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt index 705ef38..1f304b0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt @@ -1,19 +1,96 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RouteRetrieveParams -import org.onebusaway.models.RouteRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.route.RouteRetrieveParams +import org.onebusaway.models.route.RouteRetrieveResponse interface RouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve information for a specific route identified by its unique ID. */ - @JvmOverloads + fun retrieve(routeId: String): RouteRetrieveResponse = + retrieve(routeId, RouteRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RouteRetrieveResponse = retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + ): RouteRetrieveResponse = retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: RouteRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RouteRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: RouteRetrieveParams): RouteRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(routeId: String, requestOptions: RequestOptions): RouteRetrieveResponse = + retrieve(routeId, RouteRetrieveParams.none(), requestOptions) + + /** A view of [RouteService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/route/{routeID}.json`, but is otherwise + * the same as [RouteService.retrieve]. + */ + @MustBeClosed + fun retrieve(routeId: String): HttpResponseFor = + retrieve(routeId, RouteRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + ): HttpResponseFor = retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: RouteRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: RouteRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(routeId, RouteRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt index 0e6ea10..bca72fb 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt @@ -2,50 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.RouteRetrieveParams -import org.onebusaway.models.RouteRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : RouteService { +class RouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): RouteService.WithRawResponse = withRawResponse - /** Retrieve information for a specific route identified by its unique ID. */ override fun retrieve( params: RouteRetrieveParams, - requestOptions: RequestOptions - ): RouteRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "route", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): RouteRetrieveResponse = + // get /api/where/route/{routeID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: RouteRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "route", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt index 845d40d..9b00bdd 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt @@ -1,19 +1,101 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RoutesForAgencyListParams -import org.onebusaway.models.RoutesForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse interface RoutesForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve the list of all routes for a particular agency by id */ - @JvmOverloads + fun list(agencyId: String): RoutesForAgencyListResponse = + list(agencyId, RoutesForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RoutesForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + ): RoutesForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RoutesForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RoutesForAgencyListResponse + + /** @see [list] */ + fun list(params: RoutesForAgencyListParams): RoutesForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): RoutesForAgencyListResponse = + list(agencyId, RoutesForAgencyListParams.none(), requestOptions) + + /** + * A view of [RoutesForAgencyService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-agency/{agencyID}.json`, but + * is otherwise the same as [RoutesForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, RoutesForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: RoutesForAgencyListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, RoutesForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt index 858cf23..101ed80 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.RoutesForAgencyListParams -import org.onebusaway.models.RoutesForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : RoutesForAgencyService { +class RoutesForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoutesForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RoutesForAgencyService.WithRawResponse = withRawResponse - /** Retrieve the list of all routes for a particular agency by id */ override fun list( params: RoutesForAgencyListParams, - requestOptions: RequestOptions - ): RoutesForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "routes-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): RoutesForAgencyListResponse = + // get /api/where/routes-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoutesForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "routes-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt index 9cecbf9..0096c2b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt @@ -1,19 +1,50 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RoutesForLocationListParams -import org.onebusaway.models.RoutesForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse interface RoutesForLocationService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** routes-for-location */ - @JvmOverloads + fun list(params: RoutesForLocationListParams): RoutesForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RoutesForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RoutesForLocationListResponse + + /** + * A view of [RoutesForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-location.json`, but is + * otherwise the same as [RoutesForLocationService.list]. + */ + @MustBeClosed + fun list( + params: RoutesForLocationListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt index 0abe6fc..442e156 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,43 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.RoutesForLocationListParams -import org.onebusaway.models.RoutesForLocationListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : RoutesForLocationService { +class RoutesForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForLocationService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoutesForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RoutesForLocationService.WithRawResponse = withRawResponse - /** routes-for-location */ override fun list( params: RoutesForLocationListParams, - requestOptions: RequestOptions - ): RoutesForLocationListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "routes-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): RoutesForLocationListResponse = + // get /api/where/routes-for-location.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForLocationService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "routes-for-location.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt index f9a4e1b..2979d2f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt @@ -1,19 +1,106 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ScheduleForRouteRetrieveParams -import org.onebusaway.models.ScheduleForRouteRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse interface ScheduleForRouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve the full schedule for a route on a particular day */ - @JvmOverloads + fun retrieve(routeId: String): ScheduleForRouteRetrieveResponse = + retrieve(routeId, ScheduleForRouteRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ScheduleForRouteRetrieveResponse = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + ): ScheduleForRouteRetrieveResponse = retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ScheduleForRouteRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ScheduleForRouteRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: ScheduleForRouteRetrieveParams): ScheduleForRouteRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): ScheduleForRouteRetrieveResponse = + retrieve(routeId, ScheduleForRouteRetrieveParams.none(), requestOptions) + + /** + * A view of [ScheduleForRouteService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-route/{routeID}.json`, but + * is otherwise the same as [ScheduleForRouteService.retrieve]. + */ + @MustBeClosed + fun retrieve(routeId: String): HttpResponseFor = + retrieve(routeId, ScheduleForRouteRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + ): HttpResponseFor = + retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForRouteRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForRouteRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(routeId, ScheduleForRouteRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt index 00372d5..51fcebf 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ScheduleForRouteRetrieveParams -import org.onebusaway.models.ScheduleForRouteRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : ScheduleForRouteService { +class ScheduleForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForRouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ScheduleForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ScheduleForRouteService.WithRawResponse = withRawResponse - /** Retrieve the full schedule for a route on a particular day */ override fun retrieve( params: ScheduleForRouteRetrieveParams, - requestOptions: RequestOptions - ): ScheduleForRouteRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "schedule-for-route", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): ScheduleForRouteRetrieveResponse = + // get /api/where/schedule-for-route/{routeID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForRouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ScheduleForRouteRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "schedule-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt index 6893084..605661b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt @@ -1,19 +1,103 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ScheduleForStopRetrieveParams -import org.onebusaway.models.ScheduleForStopRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveResponse interface ScheduleForStopService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get schedule for a specific stop */ - @JvmOverloads + fun retrieve(stopId: String): ScheduleForStopRetrieveResponse = + retrieve(stopId, ScheduleForStopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ScheduleForStopRetrieveResponse = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + ): ScheduleForStopRetrieveResponse = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ScheduleForStopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ScheduleForStopRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: ScheduleForStopRetrieveParams): ScheduleForStopRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(stopId: String, requestOptions: RequestOptions): ScheduleForStopRetrieveResponse = + retrieve(stopId, ScheduleForStopRetrieveParams.none(), requestOptions) + + /** + * A view of [ScheduleForStopService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-stop/{stopID}.json`, but is + * otherwise the same as [ScheduleForStopService.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): HttpResponseFor = + retrieve(stopId, ScheduleForStopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + ): HttpResponseFor = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForStopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForStopRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(stopId, ScheduleForStopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt index bbeb9f0..fbf848d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ScheduleForStopRetrieveParams -import org.onebusaway.models.ScheduleForStopRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : ScheduleForStopService { +class ScheduleForStopServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForStopService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ScheduleForStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ScheduleForStopService.WithRawResponse = withRawResponse - /** Get schedule for a specific stop */ override fun retrieve( params: ScheduleForStopRetrieveParams, - requestOptions: RequestOptions - ): ScheduleForStopRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "schedule-for-stop", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): ScheduleForStopRetrieveResponse = + // get /api/where/schedule-for-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForStopService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ScheduleForStopRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "schedule-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt index 4e0c391..04b354e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt @@ -1,19 +1,48 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.SearchForRouteListParams -import org.onebusaway.models.SearchForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.searchforroute.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListResponse interface SearchForRouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for a route based on its name. */ - @JvmOverloads + fun list(params: SearchForRouteListParams): SearchForRouteListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: SearchForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SearchForRouteListResponse + + /** + * A view of [SearchForRouteService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/search/route.json`, but is otherwise the + * same as [SearchForRouteService.list]. + */ + @MustBeClosed + fun list(params: SearchForRouteListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt index c772d84..ff5e599 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,43 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.SearchForRouteListParams -import org.onebusaway.models.SearchForRouteListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : SearchForRouteService { +class SearchForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForRouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SearchForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SearchForRouteService.WithRawResponse = withRawResponse - /** Search for a route based on its name. */ override fun list( params: SearchForRouteListParams, - requestOptions: RequestOptions - ): SearchForRouteListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "search", "route.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): SearchForRouteListResponse = + // get /api/where/search/route.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForRouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "search", "route.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt index 7b8508b..f11dbd7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt @@ -1,19 +1,48 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.SearchForStopListParams -import org.onebusaway.models.SearchForStopListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.searchforstop.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListResponse interface SearchForStopService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for a stop based on its name. */ - @JvmOverloads + fun list(params: SearchForStopListParams): SearchForStopListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: SearchForStopListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SearchForStopListResponse + + /** + * A view of [SearchForStopService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/search/stop.json`, but is otherwise the + * same as [SearchForStopService.list]. + */ + @MustBeClosed + fun list(params: SearchForStopListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt index 4392c97..2c9e4b0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,43 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.SearchForStopListParams -import org.onebusaway.models.SearchForStopListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : SearchForStopService { +class SearchForStopServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SearchForStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SearchForStopService.WithRawResponse = withRawResponse - /** Search for a stop based on its name. */ override fun list( params: SearchForStopListParams, - requestOptions: RequestOptions - ): SearchForStopListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "search", "stop.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): SearchForStopListResponse = + // get /api/where/search/stop.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "search", "stop.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt index 653548d..d82d700 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt @@ -1,19 +1,96 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ShapeRetrieveParams -import org.onebusaway.models.ShapeRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.shape.ShapeRetrieveParams +import org.onebusaway.models.shape.ShapeRetrieveResponse interface ShapeService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ - @JvmOverloads + fun retrieve(shapeId: String): ShapeRetrieveResponse = + retrieve(shapeId, ShapeRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ShapeRetrieveResponse = retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + ): ShapeRetrieveResponse = retrieve(shapeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ShapeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ShapeRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: ShapeRetrieveParams): ShapeRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(shapeId: String, requestOptions: RequestOptions): ShapeRetrieveResponse = + retrieve(shapeId, ShapeRetrieveParams.none(), requestOptions) + + /** A view of [ShapeService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/shape/{shapeID}.json`, but is otherwise + * the same as [ShapeService.retrieve]. + */ + @MustBeClosed + fun retrieve(shapeId: String): HttpResponseFor = + retrieve(shapeId, ShapeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + ): HttpResponseFor = retrieve(shapeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ShapeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: ShapeRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(shapeId, ShapeRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt index 72b6132..1d1d961 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt @@ -2,50 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.ShapeRetrieveParams -import org.onebusaway.models.ShapeRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : ShapeService { +class ShapeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ShapeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ShapeService.WithRawResponse = withRawResponse - /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ override fun retrieve( params: ShapeRetrieveParams, - requestOptions: RequestOptions - ): ShapeRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "shape", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): ShapeRetrieveResponse = + // get /api/where/shape/{shapeID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ShapeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shapeId", params.shapeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "shape", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt index d4d5592..aadb2ac 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt @@ -1,19 +1,102 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopIdsForAgencyListParams -import org.onebusaway.models.StopIdsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse interface StopIdsForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stop IDs for a specific agency */ - @JvmOverloads + fun list(agencyId: String): StopIdsForAgencyListResponse = + list(agencyId, StopIdsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): StopIdsForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + ): StopIdsForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopIdsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopIdsForAgencyListResponse + + /** @see [list] */ + fun list(params: StopIdsForAgencyListParams): StopIdsForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): StopIdsForAgencyListResponse = + list(agencyId, StopIdsForAgencyListParams.none(), requestOptions) + + /** + * A view of [StopIdsForAgencyService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stop-ids-for-agency/{agencyID}.json`, but + * is otherwise the same as [StopIdsForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, StopIdsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopIdsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopIdsForAgencyListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, StopIdsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt index e78aca1..13d621b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopIdsForAgencyListParams -import org.onebusaway.models.StopIdsForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopIdsForAgencyService { +class StopIdsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopIdsForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopIdsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopIdsForAgencyService.WithRawResponse = withRawResponse - /** Get stop IDs for a specific agency */ override fun list( params: StopIdsForAgencyListParams, - requestOptions: RequestOptions - ): StopIdsForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stop-ids-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): StopIdsForAgencyListResponse = + // get /api/where/stop-ids-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopIdsForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopIdsForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stop-ids-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt index dd88877..ff15b60 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt @@ -1,19 +1,95 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopRetrieveParams -import org.onebusaway.models.StopRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stop.StopRetrieveParams +import org.onebusaway.models.stop.StopRetrieveResponse interface StopService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific stop */ - @JvmOverloads + fun retrieve(stopId: String): StopRetrieveResponse = retrieve(stopId, StopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): StopRetrieveResponse = retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + ): StopRetrieveResponse = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: StopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: StopRetrieveParams): StopRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(stopId: String, requestOptions: RequestOptions): StopRetrieveResponse = + retrieve(stopId, StopRetrieveParams.none(), requestOptions) + + /** A view of [StopService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stop/{stopID}.json`, but is otherwise the + * same as [StopService.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): HttpResponseFor = + retrieve(stopId, StopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + ): HttpResponseFor = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: StopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: StopRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(stopId, StopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt index 9a72422..78b0a9a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt @@ -2,50 +2,71 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopRetrieveParams -import org.onebusaway.models.StopRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopService { +class StopServiceImpl internal constructor(private val clientOptions: ClientOptions) : StopService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): StopService.WithRawResponse = withRawResponse - /** Get details of a specific stop */ override fun retrieve( params: StopRetrieveParams, - requestOptions: RequestOptions - ): StopRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "stop", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): StopRetrieveResponse = + // get /api/where/stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: StopRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "stop", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt index 48ccc54..6bd2fde 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt @@ -1,19 +1,100 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForAgencyListParams -import org.onebusaway.models.StopsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforagency.StopsForAgencyListParams +import org.onebusaway.models.stopsforagency.StopsForAgencyListResponse interface StopsForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stops for a specific agency */ - @JvmOverloads + fun list(agencyId: String): StopsForAgencyListResponse = + list(agencyId, StopsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): StopsForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + ): StopsForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopsForAgencyListResponse + + /** @see [list] */ + fun list(params: StopsForAgencyListParams): StopsForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): StopsForAgencyListResponse = + list(agencyId, StopsForAgencyListParams.none(), requestOptions) + + /** + * A view of [StopsForAgencyService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-agency/{agencyID}.json`, but is + * otherwise the same as [StopsForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, StopsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: StopsForAgencyListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, StopsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt index 6b64894..ce8ac3b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForAgencyListParams -import org.onebusaway.models.StopsForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopsForAgencyService { +class StopsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForAgencyService.WithRawResponse = withRawResponse - /** Get stops for a specific agency */ override fun list( params: StopsForAgencyListParams, - requestOptions: RequestOptions - ): StopsForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stops-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): StopsForAgencyListResponse = + // get /api/where/stops-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stops-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt index 5645cfb..fc4606c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt @@ -1,19 +1,50 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForLocationListParams -import org.onebusaway.models.StopsForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse interface StopsForLocationService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** stops-for-location */ - @JvmOverloads + fun list(params: StopsForLocationListParams): StopsForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopsForLocationListResponse + + /** + * A view of [StopsForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-location.json`, but is + * otherwise the same as [StopsForLocationService.list]. + */ + @MustBeClosed + fun list( + params: StopsForLocationListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt index 89b6807..37a9da8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,43 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForLocationListParams -import org.onebusaway.models.StopsForLocationListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopsForLocationService { +class StopsForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForLocationService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForLocationService.WithRawResponse = withRawResponse - /** stops-for-location */ override fun list( params: StopsForLocationListParams, - requestOptions: RequestOptions - ): StopsForLocationListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "stops-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): StopsForLocationListResponse = + // get /api/where/stops-for-location.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForLocationService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "stops-for-location.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt index 72c87c4..5c91312 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt @@ -1,19 +1,98 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForRouteListParams -import org.onebusaway.models.StopsForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforroute.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse interface StopsForRouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stops for a specific route */ - @JvmOverloads + fun list(routeId: String): StopsForRouteListResponse = + list(routeId, StopsForRouteListParams.none()) + + /** @see [list] */ + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): StopsForRouteListResponse = list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + ): StopsForRouteListResponse = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopsForRouteListResponse + + /** @see [list] */ + fun list(params: StopsForRouteListParams): StopsForRouteListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(routeId: String, requestOptions: RequestOptions): StopsForRouteListResponse = + list(routeId, StopsForRouteListParams.none(), requestOptions) + + /** + * A view of [StopsForRouteService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-route/{routeID}.json`, but is + * otherwise the same as [StopsForRouteService.list]. + */ + @MustBeClosed + fun list(routeId: String): HttpResponseFor = + list(routeId, StopsForRouteListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + ): HttpResponseFor = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: StopsForRouteListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(routeId, StopsForRouteListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt index f5a5459..59690be 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForRouteListParams -import org.onebusaway.models.StopsForRouteListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : StopsForRouteService { +class StopsForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForRouteService.WithRawResponse = withRawResponse - /** Get stops for a specific route */ override fun list( params: StopsForRouteListParams, - requestOptions: RequestOptions - ): StopsForRouteListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stops-for-route", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): StopsForRouteListResponse = + // get /api/where/stops-for-route/{routeID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForRouteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stops-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt index 5040d0f..942f586 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt @@ -1,19 +1,99 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripDetailRetrieveParams -import org.onebusaway.models.TripDetailRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse interface TripDetailService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve Trip Details */ - @JvmOverloads + fun retrieve(tripId: String): TripDetailRetrieveResponse = + retrieve(tripId, TripDetailRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TripDetailRetrieveResponse = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + ): TripDetailRetrieveResponse = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripDetailRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripDetailRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: TripDetailRetrieveParams): TripDetailRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(tripId: String, requestOptions: RequestOptions): TripDetailRetrieveResponse = + retrieve(tripId, TripDetailRetrieveParams.none(), requestOptions) + + /** A view of [TripDetailService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip-details/{tripID}.json`, but is + * otherwise the same as [TripDetailService.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): HttpResponseFor = + retrieve(tripId, TripDetailRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + ): HttpResponseFor = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripDetailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripDetailRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(tripId, TripDetailRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt index 4229393..4c96e8d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt @@ -2,51 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripDetailRetrieveParams -import org.onebusaway.models.TripDetailRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripDetailService { +class TripDetailServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripDetailService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripDetailService.WithRawResponse = withRawResponse - /** Retrieve Trip Details */ override fun retrieve( params: TripDetailRetrieveParams, - requestOptions: RequestOptions - ): TripDetailRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trip-details", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): TripDetailRetrieveResponse = + // get /api/where/trip-details/{tripID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripDetailRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trip-details", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt index ed0659a..e0c77c2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt @@ -1,19 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripForVehicleRetrieveParams -import org.onebusaway.models.TripForVehicleRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse interface TripForVehicleService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve trip for a specific vehicle */ - @JvmOverloads + fun retrieve(vehicleId: String): TripForVehicleRetrieveResponse = + retrieve(vehicleId, TripForVehicleRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TripForVehicleRetrieveResponse = + retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + ): TripForVehicleRetrieveResponse = retrieve(vehicleId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripForVehicleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripForVehicleRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: TripForVehicleRetrieveParams): TripForVehicleRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + requestOptions: RequestOptions, + ): TripForVehicleRetrieveResponse = + retrieve(vehicleId, TripForVehicleRetrieveParams.none(), requestOptions) + + /** + * A view of [TripForVehicleService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip-for-vehicle/{vehicleID}.json`, but + * is otherwise the same as [TripForVehicleService.retrieve]. + */ + @MustBeClosed + fun retrieve(vehicleId: String): HttpResponseFor = + retrieve(vehicleId, TripForVehicleRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + ): HttpResponseFor = + retrieve(vehicleId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripForVehicleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripForVehicleRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(vehicleId, TripForVehicleRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt index a1251db..bbb0d41 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripForVehicleRetrieveParams -import org.onebusaway.models.TripForVehicleRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripForVehicleService { +class TripForVehicleServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripForVehicleService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripForVehicleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripForVehicleService.WithRawResponse = withRawResponse - /** Retrieve trip for a specific vehicle */ override fun retrieve( params: TripForVehicleRetrieveParams, - requestOptions: RequestOptions - ): TripForVehicleRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "trip-for-vehicle", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): TripForVehicleRetrieveResponse = + // get /api/where/trip-for-vehicle/{vehicleID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripForVehicleService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripForVehicleRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("vehicleId", params.vehicleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "trip-for-vehicle", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt index ad7c940..170dec6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt @@ -1,19 +1,95 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripRetrieveParams -import org.onebusaway.models.TripRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.trip.TripRetrieveParams +import org.onebusaway.models.trip.TripRetrieveResponse interface TripService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific trip */ - @JvmOverloads + fun retrieve(tripId: String): TripRetrieveResponse = retrieve(tripId, TripRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TripRetrieveResponse = retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + ): TripRetrieveResponse = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: TripRetrieveParams): TripRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(tripId: String, requestOptions: RequestOptions): TripRetrieveResponse = + retrieve(tripId, TripRetrieveParams.none(), requestOptions) + + /** A view of [TripService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip/{tripID}.json`, but is otherwise the + * same as [TripService.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): HttpResponseFor = + retrieve(tripId, TripRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + ): HttpResponseFor = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: TripRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(tripId, TripRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt index 484fe4c..6cd67ed 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt @@ -2,50 +2,71 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripRetrieveParams -import org.onebusaway.models.TripRetrieveResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripService { +class TripServiceImpl internal constructor(private val clientOptions: ClientOptions) : TripService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): TripService.WithRawResponse = withRawResponse - /** Get details of a specific trip */ override fun retrieve( params: TripRetrieveParams, - requestOptions: RequestOptions - ): TripRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trip", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): TripRetrieveResponse = + // get /api/where/trip/{tripID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trip", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt index ba9a53d..f313dba 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt @@ -1,19 +1,50 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripsForLocationListParams -import org.onebusaway.models.TripsForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListResponse interface TripsForLocationService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve trips for a given location */ - @JvmOverloads + fun list(params: TripsForLocationListParams): TripsForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: TripsForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripsForLocationListResponse + + /** + * A view of [TripsForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-location.json`, but is + * otherwise the same as [TripsForLocationService.list]. + */ + @MustBeClosed + fun list( + params: TripsForLocationListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt index 7133779..6a5576b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,43 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripsForLocationListParams -import org.onebusaway.models.TripsForLocationListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripsForLocationService { +class TripsForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForLocationService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripsForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripsForLocationService.WithRawResponse = withRawResponse - /** Retrieve trips for a given location */ override fun list( params: TripsForLocationListParams, - requestOptions: RequestOptions - ): TripsForLocationListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trips-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): TripsForLocationListResponse = + // get /api/where/trips-for-location.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForLocationService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trips-for-location.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt index 22f114a..449719e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt @@ -1,19 +1,98 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripsForRouteListParams -import org.onebusaway.models.TripsForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripsforroute.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse interface TripsForRouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for active trips for a specific route. */ - @JvmOverloads + fun list(routeId: String): TripsForRouteListResponse = + list(routeId, TripsForRouteListParams.none()) + + /** @see [list] */ + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TripsForRouteListResponse = list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + ): TripsForRouteListResponse = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: TripsForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripsForRouteListResponse + + /** @see [list] */ + fun list(params: TripsForRouteListParams): TripsForRouteListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(routeId: String, requestOptions: RequestOptions): TripsForRouteListResponse = + list(routeId, TripsForRouteListParams.none(), requestOptions) + + /** + * A view of [TripsForRouteService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-route/{routeID}.json`, but is + * otherwise the same as [TripsForRouteService.list]. + */ + @MustBeClosed + fun list(routeId: String): HttpResponseFor = + list(routeId, TripsForRouteListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + ): HttpResponseFor = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: TripsForRouteListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(routeId, TripsForRouteListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt index b7f5799..f63ee3a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.TripsForRouteListParams -import org.onebusaway.models.TripsForRouteListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : TripsForRouteService { +class TripsForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripsForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripsForRouteService.WithRawResponse = withRawResponse - /** Search for active trips for a specific route. */ override fun list( params: TripsForRouteListParams, - requestOptions: RequestOptions - ): TripsForRouteListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "trips-for-route", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): TripsForRouteListResponse = + // get /api/where/trips-for-route/{routeID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TripsForRouteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "trips-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt index 6fb09be..836379a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt @@ -1,19 +1,102 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.VehiclesForAgencyListParams -import org.onebusaway.models.VehiclesForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse interface VehiclesForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get vehicles for a specific agency */ - @JvmOverloads + fun list(agencyId: String): VehiclesForAgencyListResponse = + list(agencyId, VehiclesForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VehiclesForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + ): VehiclesForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: VehiclesForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): VehiclesForAgencyListResponse + + /** @see [list] */ + fun list(params: VehiclesForAgencyListParams): VehiclesForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): VehiclesForAgencyListResponse = + list(agencyId, VehiclesForAgencyListParams.none(), requestOptions) + + /** + * A view of [VehiclesForAgencyService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/vehicles-for-agency/{agencyID}.json`, but + * is otherwise the same as [VehiclesForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, VehiclesForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: VehiclesForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: VehiclesForAgencyListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, VehiclesForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt index 65a44c4..2a854ae 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt @@ -2,56 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkError -import org.onebusaway.models.VehiclesForAgencyListParams -import org.onebusaway.models.VehiclesForAgencyListResponse +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 -constructor( - private val clientOptions: ClientOptions, -) : VehiclesForAgencyService { +class VehiclesForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + VehiclesForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: VehiclesForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): VehiclesForAgencyService.WithRawResponse = withRawResponse - /** Get vehicles for a specific agency */ override fun list( params: VehiclesForAgencyListParams, - requestOptions: RequestOptions - ): VehiclesForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "vehicles-for-agency", - "${params.getPathParam(0)}.json" - ) - .putAllQueryParams(clientOptions.queryParams.asMap()) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): VehiclesForAgencyListResponse = + // get /api/where/vehicles-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VehiclesForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: VehiclesForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "vehicles-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/TestServerExtension.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/TestServerExtension.kt index 0902411..ce4f7d3 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/TestServerExtension.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/TestServerExtension.kt @@ -36,7 +36,7 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { $ prism mock path/to/your.openapi.yml """ .trimIndent(), - e + e, ) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ObjectMappersTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ObjectMappersTest.kt new file mode 100644 index 0000000..9033497 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ObjectMappersTest.kt @@ -0,0 +1,102 @@ +package org.onebusaway.core + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime +import kotlin.reflect.KClass +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import org.junitpioneer.jupiter.cartesian.CartesianTest + +internal class ObjectMappersTest { + + internal class ClassWithBooleanFieldPrefixedWithIs(private val isActive: JsonField) { + + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + } + + @Test + fun write_whenFieldPrefixedWithIs_keepsPrefix() { + val value = ClassWithBooleanFieldPrefixedWithIs(JsonField.of(true)) + + val json = jsonMapper().writeValueAsString(value) + + assertThat(json).isEqualTo("{\"is_active\":true}") + } + + internal class Class(@get:JsonProperty("field") @JsonProperty("field") val field: String) + + enum class ShapeTestCase(val value: Any, val kClass: KClass<*>) { + STRING("Hello World!", String::class), + BOOLEAN(true, Boolean::class), + FLOAT(3.14F, Float::class), + DOUBLE(3.14, Double::class), + INTEGER(42, Int::class), + LONG(42L, Long::class), + MAP(mapOf("property" to "value"), Map::class), + CLASS(Class("Hello World!"), Class::class), + LIST(listOf(1, 2, 3), List::class); + + companion object { + val VALID_CONVERSIONS = + listOf( + FLOAT to DOUBLE, + FLOAT to INTEGER, + FLOAT to LONG, + DOUBLE to FLOAT, + DOUBLE to INTEGER, + DOUBLE to LONG, + INTEGER to FLOAT, + INTEGER to DOUBLE, + INTEGER to LONG, + LONG to FLOAT, + LONG to DOUBLE, + LONG to INTEGER, + CLASS to MAP, + // These aren't actually valid, but coercion configs don't work for String until + // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 + // We currently test on v2.13.4. + BOOLEAN to STRING, + FLOAT to STRING, + DOUBLE to STRING, + INTEGER to STRING, + LONG to STRING, + ) + } + } + + @CartesianTest + fun read(@CartesianTest.Enum shape1: ShapeTestCase, @CartesianTest.Enum shape2: ShapeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(shape1.value) + + val e = catchThrowable { jsonMapper.readValue(json, shape2.kClass.java) } + + if (shape1 == shape2 || shape1 to shape2 in ShapeTestCase.VALID_CONVERSIONS) { + assertThat(e).isNull() + } else { + assertThat(e).isInstanceOf(MismatchedInputException::class.java) + } + } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue(json) } + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt index 01df843..8fc02c7 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt @@ -14,13 +14,13 @@ internal class PhantomReachableTest { // Pass an inline object for the object to observe so that it becomes immediately // unreachable. Any(), - closeable + closeable, ) assertThat(closed).isFalse() System.gc() - Thread.sleep(3000) + Thread.sleep(100) assertThat(closed).isTrue() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/UtilsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/UtilsTest.kt new file mode 100644 index 0000000..35c3319 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/UtilsTest.kt @@ -0,0 +1,33 @@ +package org.onebusaway.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtilsTest { + @Test + fun contentDeepEquals() { + assertThat(42 contentEquals 42).isTrue() + assertThat(42 contentEquals "Hello World!").isFalse() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 3)).isTrue() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 4)).isFalse() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) + ) + .isTrue() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1), byteArrayOf(2, 3)) + ) + .isFalse() + } + + @Test + fun contentToString() { + assertThat((42).contentToString()).isEqualTo("42") + assertThat("Hello World!".contentToString()).isEqualTo("Hello World!") + assertThat(byteArrayOf(1, 2, 3).contentToString()).isEqualTo("[1, 2, 3]") + assertThat(arrayOf(byteArrayOf(1, 2), byteArrayOf(3)).contentToString()) + .isEqualTo("[[1, 2], [3]]") + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ValuesTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ValuesTest.kt new file mode 100644 index 0000000..e160c68 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ValuesTest.kt @@ -0,0 +1,144 @@ +package org.onebusaway.core + +import java.util.Optional +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ValuesTest { + companion object { + private val NON_JSON = Any() + } + + enum class TestCase( + val value: JsonField<*>, + val expectedIsMissing: Boolean = false, + val expectedIsNull: Boolean = false, + val expectedAsKnown: Optional<*> = Optional.empty(), + val expectedAsBoolean: Optional = Optional.empty(), + val expectedAsNumber: Optional = Optional.empty(), + val expectedAsString: Optional = Optional.empty(), + val expectedAsArray: Optional> = Optional.empty(), + val expectedAsObject: Optional> = Optional.empty(), + ) { + MISSING(JsonMissing.of(), expectedIsMissing = true), + NULL(JsonNull.of(), expectedIsNull = true), + KNOWN(KnownValue.of(NON_JSON), expectedAsKnown = Optional.of(NON_JSON)), + KNOWN_BOOLEAN( + KnownValue.of(true), + expectedAsKnown = Optional.of(true), + expectedAsBoolean = Optional.of(true), + ), + BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), + KNOWN_NUMBER( + KnownValue.of(42), + expectedAsKnown = Optional.of(42), + expectedAsNumber = Optional.of(42), + ), + NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), + KNOWN_STRING( + KnownValue.of("hello"), + expectedAsKnown = Optional.of("hello"), + expectedAsString = Optional.of("hello"), + ), + STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), + KNOWN_ARRAY_NOT_ALL_JSON( + KnownValue.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + ), + KNOWN_ARRAY( + KnownValue.of(listOf("a", "b", "c")), + expectedAsKnown = Optional.of(listOf("a", "b", "c")), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + ARRAY( + JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + KNOWN_OBJECT_NOT_ALL_STRING_KEYS( + KnownValue.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + ), + KNOWN_OBJECT_NOT_ALL_JSON( + KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + ), + KNOWN_OBJECT( + KnownValue.of(mapOf("a" to "b", "b" to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + OBJECT( + JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + } + + @ParameterizedTest + @EnumSource + fun isMissing(testCase: TestCase) { + val isMissing = testCase.value.isMissing() + + assertThat(isMissing).isEqualTo(testCase.expectedIsMissing) + } + + @ParameterizedTest + @EnumSource + fun isNull(testCase: TestCase) { + val isNull = testCase.value.isNull() + + assertThat(isNull).isEqualTo(testCase.expectedIsNull) + } + + @ParameterizedTest + @EnumSource + fun asKnown(testCase: TestCase) { + val known = testCase.value.asKnown() + + assertThat(known).isEqualTo(testCase.expectedAsKnown) + } + + @ParameterizedTest + @EnumSource + fun asBoolean(testCase: TestCase) { + val boolean = testCase.value.asBoolean() + + assertThat(boolean).isEqualTo(testCase.expectedAsBoolean) + } + + @ParameterizedTest + @EnumSource + fun asNumber(testCase: TestCase) { + val number = testCase.value.asNumber() + + assertThat(number).isEqualTo(testCase.expectedAsNumber) + } + + @ParameterizedTest + @EnumSource + fun asString(testCase: TestCase) { + val string = testCase.value.asString() + + assertThat(string).isEqualTo(testCase.expectedAsString) + } + + @ParameterizedTest + @EnumSource + fun asArray(testCase: TestCase) { + val array = testCase.value.asArray() + + assertThat(array).isEqualTo(testCase.expectedAsArray) + } + + @ParameterizedTest + @EnumSource + fun asObject(testCase: TestCase) { + val obj = testCase.value.asObject() + + assertThat(obj).isEqualTo(testCase.expectedAsObject) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/AsyncStreamResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/AsyncStreamResponseTest.kt new file mode 100644 index 0000000..805169f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/AsyncStreamResponseTest.kt @@ -0,0 +1,268 @@ +package org.onebusaway.core.http + +import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.stream.Stream +import kotlin.streams.asStream +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.* + +@ExtendWith(MockitoExtension::class) +internal class AsyncStreamResponseTest { + + companion object { + private val ERROR = RuntimeException("ERROR!") + } + + private val streamResponse = + spy> { + doReturn(Stream.of("chunk1", "chunk2", "chunk3")).whenever(it).stream() + } + private val erroringStreamResponse = + spy> { + doReturn( + sequence { + yield("chunk1") + yield("chunk2") + throw ERROR + } + .asStream() + ) + .whenever(it) + .stream() + } + private val executor = + spy { + doAnswer { invocation -> invocation.getArgument(0).run() } + .whenever(it) + .execute(any()) + } + private val handler = mock>() + + @Test + fun subscribe_whenAlreadySubscribed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.subscribe {} + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe more than once") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenClosed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.close() + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe after the response is closed") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletesAfterClose_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + asyncStreamResponse.close() + + future.complete(streamResponse) + + verify(handler, never()).onNext(any()) + verify(handler, never()).onComplete(any()) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureErrors_callsOnComplete() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.completeExceptionally(ERROR) + + verify(handler, never()).onNext(any()) + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletes_runsHandler() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(streamResponse) + + inOrder(handler, streamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onNext("chunk3") + verify(handler, times(1)).onComplete(Optional.empty()) + verify(streamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenStreamErrors_callsOnCompleteEarly() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(erroringStreamResponse) + + inOrder(handler, erroringStreamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(erroringStreamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureNotCompleted_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.completeExceptionally(ERROR) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedButStillStreaming_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamCompleted_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithoutThrowableThrows_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithThrowableThrows_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenClosed_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun close_whenNotClosed_closesStreamResponse() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + asyncStreamResponse.close() + future.complete(streamResponse) + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenAlreadyClosed_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + future.complete(streamResponse) + + asyncStreamResponse.close() + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenFutureErrors_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + assertDoesNotThrow { future.completeExceptionally(ERROR) } + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt index 94b91cf..3f4ec78 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt @@ -1,8 +1,6 @@ package org.onebusaway.core.http import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -11,28 +9,28 @@ internal class HeadersTest { enum class TestCase( val headers: Headers, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( Headers.builder().put("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( Headers.builder().put("name1", "value").put("name2", "value").build(), expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( Headers.builder().put("name", "value1").put("name", "value2").build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( Headers.builder() @@ -40,7 +38,7 @@ internal class HeadersTest { .put("name", listOf("value1", "value2")) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_CASE_INSENSITIVE( Headers.builder() @@ -49,25 +47,25 @@ internal class HeadersTest { .put("nAmE", "value3") .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), PUT_ALL_MAP( Headers.builder() .putAll( mapOf( "name1" to listOf("value1", "value2"), - "name2" to listOf("value1", "value2") + "name2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_ALL_CASE_INSENSITIVE( Headers.builder() @@ -75,32 +73,32 @@ internal class HeadersTest { mapOf( "name" to listOf("value1"), "NAME" to listOf("value2"), - "nAmE" to listOf("value3") + "nAmE" to listOf("value3"), ) ) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), REMOVE_ABSENT( Headers.builder().remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( Headers.builder().put("name", "value").remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_CASE_INSENSITIVE( Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( Headers.builder() @@ -109,7 +107,7 @@ internal class HeadersTest { .removeAll(setOf("name1", "name2", "name3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -118,22 +116,22 @@ internal class HeadersTest { .removeAll(setOf("NAME1", "nAmE3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( Headers.builder().put("name1", "value").put("name2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( Headers.builder().replace("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( Headers.builder().put("name", "value1").replace("name", "value2").build(), expectedMap = mapOf("name" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( Headers.builder() @@ -141,12 +139,12 @@ internal class HeadersTest { .replace("name", "value3") .build(), expectedMap = mapOf("name" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( Headers.builder().replace("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( Headers.builder() @@ -154,7 +152,7 @@ internal class HeadersTest { .replace("name", listOf("value2", "value3")) .build(), expectedMap = mapOf("name" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( Headers.builder() @@ -162,7 +160,7 @@ internal class HeadersTest { .replace("name", listOf("value3", "value4")) .build(), expectedMap = mapOf("name" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_CASE_INSENSITIVE( Headers.builder() @@ -170,7 +168,7 @@ internal class HeadersTest { .replace("NAME", listOf("value2", "value3")) .build(), expectedMap = mapOf("NAME" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( Headers.builder() @@ -183,9 +181,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( Headers.builder() @@ -198,9 +196,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -209,8 +207,8 @@ internal class HeadersTest { .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) .build(), expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), - expectedSize = 2 - ) + expectedSize = 2, + ), } @ParameterizedTest @@ -241,34 +239,4 @@ internal class HeadersTest { assertThat(size).isEqualTo(testCase.expectedSize) } - - @ParameterizedTest - @EnumSource - fun namesAreImmutable(testCase: TestCase) { - val headers = testCase.headers - val headerNamesCopy = headers.names().toSet() - - val throwable = catchThrowable { - (headers.names() as MutableSet).add("another name") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(headers.names()).isEqualTo(headerNamesCopy) - } - - @ParameterizedTest - @EnumSource - fun valuesAreImmutable(testCase: TestCase) { - val headers = testCase.headers - assumeThat(headers.size).isNotEqualTo(0) - val name = headers.names().first() - val headerValuesCopy = headers.values(name).toList() - - val throwable = catchThrowable { - (headers.values(name) as MutableList).add("another value") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(headers.values(name)).isEqualTo(headerValuesCopy) - } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HttpRequestTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HttpRequestTest.kt deleted file mode 100644 index 1a19904..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HttpRequestTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package org.onebusaway.core.http - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class HttpRequestTest { - - @Test - fun caseInsensitiveHeadersAccessors() { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .putHeader("something_lowercase", "lowercase") - .putHeader("Something_Capitalized", "Capitalized") - .putHeader("SOMETHING_UPPERCASE", "UPPERCASE") - .build() - assertThat(request.headers.get("SOMETHING_LOWERCASE").getOrNull(0)).isEqualTo("lowercase") - assertThat(request.headers.get("something_capitalized").getOrNull(0)) - .isEqualTo("Capitalized") - assertThat(request.headers.get("Something_Uppercase").getOrNull(0)).isEqualTo("UPPERCASE") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt index 0c0b4c5..d145396 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt @@ -1,8 +1,6 @@ package org.onebusaway.core.http import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -11,28 +9,28 @@ internal class QueryParamsTest { enum class TestCase( val queryParams: QueryParams, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( QueryParams.builder().put("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( QueryParams.builder().put("key1", "value").put("key2", "value").build(), expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( QueryParams.builder().put("key", "value1").put("key", "value2").build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( QueryParams.builder() @@ -40,40 +38,40 @@ internal class QueryParamsTest { .put("key", listOf("value1", "value2")) .build(), expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_MAP( QueryParams.builder() .putAll( mapOf( "key1" to listOf("value1", "value2"), - "key2" to listOf("value1", "value2") + "key2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REMOVE_ABSENT( QueryParams.builder().remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( QueryParams.builder().put("key", "value").remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( QueryParams.builder() @@ -82,22 +80,22 @@ internal class QueryParamsTest { .removeAll(setOf("key1", "key2", "key3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( QueryParams.builder().replace("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( QueryParams.builder().put("key", "value1").replace("key", "value2").build(), expectedMap = mapOf("key" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( QueryParams.builder() @@ -105,12 +103,12 @@ internal class QueryParamsTest { .replace("key", "value3") .build(), expectedMap = mapOf("key" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( QueryParams.builder().replace("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( QueryParams.builder() @@ -118,7 +116,7 @@ internal class QueryParamsTest { .replace("key", listOf("value2", "value3")) .build(), expectedMap = mapOf("key" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( QueryParams.builder() @@ -126,7 +124,7 @@ internal class QueryParamsTest { .replace("key", listOf("value3", "value4")) .build(), expectedMap = mapOf("key" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( QueryParams.builder() @@ -139,9 +137,9 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( QueryParams.builder() @@ -156,10 +154,10 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 - ) + expectedSize = 3, + ), } @ParameterizedTest @@ -179,34 +177,4 @@ internal class QueryParamsTest { assertThat(size).isEqualTo(testCase.expectedSize) } - - @ParameterizedTest - @EnumSource - fun keysAreImmutable(testCase: TestCase) { - val queryParams = testCase.queryParams - val queryParamKeysCopy = queryParams.keys().toSet() - - val throwable = catchThrowable { - (queryParams.keys() as MutableSet).add("another key") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(queryParams.keys()).isEqualTo(queryParamKeysCopy) - } - - @ParameterizedTest - @EnumSource - fun valuesAreImmutable(testCase: TestCase) { - val queryParams = testCase.queryParams - assumeThat(queryParams.size).isNotEqualTo(0) - val key = queryParams.keys().first() - val queryParamValuesCopy = queryParams.values(key).toList() - - val throwable = catchThrowable { - (queryParams.values(key) as MutableList).add("another value") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(queryParams.values(key)).isEqualTo(queryParamValuesCopy) - } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt index 22b8b7f..49ef7ce 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt @@ -4,62 +4,115 @@ 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.Test +import org.junit.jupiter.api.parallel.ResourceLock import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource import org.onebusaway.client.okhttp.OkHttpClient +import org.onebusaway.core.RequestOptions @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") internal class RetryingHttpClientTest { + private var openResponseCount = 0 private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - httpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + httpClient = + object : HttpClient { + + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = + okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } + + override fun close() = okHttpClient.close() + + private fun trackClose(response: HttpResponse): HttpResponse { + openResponseCount++ + return object : HttpResponse { + + private var isClosed = false + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = response.body() + + override fun close() { + response.close() + if (isClosed) { + return + } + openResponseCount-- + isClosed = true + } + } + } + } resetAllScenarios() } - @Test - fun byDefaultShouldNotAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() - val response = retryingClient.execute(request) + val retryingClient = retryingHttpClientBuilder().build() + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async, + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } - @Test - fun whenProvidedShouldAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) .willReturn(ok()) ) val retryingClient = - RetryingHttpClient.builder() - .httpClient(httpClient) - .idempotencyHeader("X-Some-Header") - .build() - val response = retryingClient.execute(request) + retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async, + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun retryAfterHeader(async: Boolean) { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + fun execute_withRetryAfterHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // first we fail with a retry after header given as a date + // First we fail with a retry after header given as a date + .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) .willReturn( serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") @@ -68,52 +121,50 @@ internal class RetryingHttpClientTest { ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we fail with a retry after header given as a delay + // Then we fail with a retry after header given as a delay + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DATE") .willReturn(serviceUnavailable().withHeader("Retry-After", "1.234")) .willSetStateTo("RETRY_AFTER_DELAY") ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we return a success + // Then we return a success + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DELAY") .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async, + ) assertThat(response.statusCode()).isEqualTo(200) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("0")) + .withHeader("x-stainless-retry-count", equalTo("0")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("1")) + .withHeader("x-stainless-retry-count", equalTo("1")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("2")) + .withHeader("x-stainless-retry-count", equalTo("2")), ) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun overwriteRetryCountHeader(async: Boolean) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .putHeader("x-stainless-retry-count", "42") - .build() + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date @@ -130,25 +181,30 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async, + ) assertThat(response.statusCode()).isEqualTo(200) verify( 2, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("42")) + .withHeader("x-stainless-retry-count", equalTo("42")), ) + assertNoResponseLeaks() } - @Test - fun retryAfterMsHeader() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") @@ -163,10 +219,37 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() - val response = retryingClient.execute(request) + val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async, + ) + assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } + + private fun retryingHttpClientBuilder() = + RetryingHttpClient.builder() + .httpClient(httpClient) + // Use a no-op `Sleeper` to make the test fast. + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + } + ) + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) + + // When retrying, all failed responses should be closed. Only the final returned response should + // be open. + private fun assertNoResponseLeaks() = assertThat(openResponseCount).isEqualTo(1) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt deleted file mode 100644 index 8a87713..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt +++ /dev/null @@ -1,105 +0,0 @@ -package org.onebusaway.core.http - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.core.* - -internal class SerializerTest { - @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) - @NoAutoDetect - class ClassWithBooleanFieldPrefixedWithIs - private constructor( - private val isActive: JsonField, - private val additionalProperties: Map, - ) { - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun isActive(): Boolean? = isActive.getNullable("is_active") - - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate() = apply { - if (!validated) { - isActive() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - isActive, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" - - companion object { - fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - private var isActive: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - @JsonProperty("is_active") - @ExcludeMissing - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs( - isActive, - additionalProperties.toImmutable(), - ) - } - } - - @Test - fun serializeBooleanPrefixedWithIs() { - val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() - assertThat(jsonMapper().writeValueAsString(value)).isEqualTo("{\"is_active\":true}") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt deleted file mode 100644 index a926379..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class ArrivalAndDepartureListParamsTest { - - @Test - fun createArrivalAndDepartureListParams() { - ArrivalAndDepartureListParams.builder() - .stopId("stopID") - .minutesAfter(123L) - .minutesBefore(123L) - .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - } - - @Test - fun getQueryParams() { - val params = - ArrivalAndDepartureListParams.builder() - .stopId("stopID") - .minutesAfter(123L) - .minutesBefore(123L) - .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - val expected = mutableMapOf>() - expected.put("minutesAfter", listOf("123")) - expected.put("minutesBefore", listOf("123")) - expected.put("time", listOf("2019-12-27T18:11:19.117Z")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = ArrivalAndDepartureListParams.builder().stopId("stopID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = ArrivalAndDepartureListParams.builder().stopId("stopID").build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt deleted file mode 100644 index 1dcf6c7..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class ArrivalAndDepartureRetrieveParamsTest { - - @Test - fun createArrivalAndDepartureRetrieveParams() { - ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") - .serviceDate(123L) - .tripId("tripId") - .stopSequence(123L) - .time(123L) - .vehicleId("vehicleId") - .build() - } - - @Test - fun getQueryParams() { - val params = - ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") - .serviceDate(123L) - .tripId("tripId") - .stopSequence(123L) - .time(123L) - .vehicleId("vehicleId") - .build() - val expected = mutableMapOf>() - expected.put("serviceDate", listOf("123")) - expected.put("tripId", listOf("tripId")) - expected.put("stopSequence", listOf("123")) - expected.put("time", listOf("123")) - expected.put("vehicleId", listOf("vehicleId")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = - ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") - .serviceDate(123L) - .tripId("tripId") - .build() - val expected = mutableMapOf>() - expected.put("serviceDate", listOf("123")) - expected.put("tripId", listOf("tripId")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = - ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") - .serviceDate(123L) - .tripId("tripId") - .build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt index 85bbd9b..f237544 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt @@ -2,175 +2,144 @@ package org.onebusaway.models +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper -class ReferencesTest { +internal class ReferencesTest { @Test - fun createReferences() { + fun create() { val references = References.builder() - .agencies( - listOf( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() ) - .routes( - listOf( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(123L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") - .build() - ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() ) - .situations( - listOf( - References.Situation.builder() - .id("id") - .creationTime(123L) - .activeWindows( - listOf( - References.Situation.ActiveWindow.builder() - .from(123L) - .to(123L) - .build() - ) - ) - .allAffects( - listOf( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) - ) - .consequenceMessage("consequenceMessage") - .consequences( - listOf( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder().from(0L).to(0L).build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails.builder() + .diversionPath( References.Situation.Consequence.ConditionDetails + .DiversionPath .builder() - .diversionPath( - References.Situation.Consequence - .ConditionDetails - .DiversionPath - .builder() - .length(123L) - .levels("levels") - .points("points") - .build() - ) - .diversionStopIds(listOf("string")) + .length(0L) + .levels("levels") + .points("points") .build() ) + .addDiversionStopId("string") .build() ) - ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .publicationWindows( - listOf( - References.Situation.PublicationWindow.builder() - .from(123L) - .to(123L) - .build() - ) - ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") - .build() - ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") - .build() - ) - .build() - ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder().from(0L).to(0L).build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url(References.Situation.Url.builder().lang("lang").value("value").build()) + .build() ) - .stops( - listOf( - References.Stop.builder() - .id("id") - .lat(42.23) - .lon(42.23) - .name("name") - .parent("parent") - .routeIds(listOf("string")) - .staticRouteIds(listOf("string")) - .code("code") - .direction("direction") - .locationType(123L) - .wheelchairBoarding("wheelchairBoarding") - .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() ) - .stopTimes( - listOf( - References.StopTime.builder() - .arrivalTime(123L) - .departureTime(123L) - .distanceAlongTrip(42.23) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() ) - .trips( - listOf( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(123L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() ) .build() - assertThat(references).isNotNull + assertThat(references.agencies()) .containsExactly( References.Agency.builder() @@ -191,7 +160,7 @@ class ReferencesTest { References.Route.builder() .id("id") .agencyId("agencyId") - .type(123L) + .type(0L) .color("color") .description("description") .longName("longName") @@ -205,45 +174,39 @@ class ReferencesTest { .containsExactly( References.Situation.builder() .id("id") - .creationTime(123L) - .activeWindows( - listOf( - References.Situation.ActiveWindow.builder().from(123L).to(123L).build() - ) + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder().from(0L).to(0L).build() ) - .allAffects( - listOf( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() ) .consequenceMessage("consequenceMessage") - .consequences( - listOf( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( - References.Situation.Consequence.ConditionDetails.builder() - .diversionPath( - References.Situation.Consequence.ConditionDetails - .DiversionPath - .builder() - .length(123L) - .levels("levels") - .points("points") - .build() - ) - .diversionStopIds(listOf("string")) - .build() - ) - .build() - ) + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails.builder() + .diversionPath( + References.Situation.Consequence.ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() ) .description( References.Situation.Description.builder() @@ -251,13 +214,8 @@ class ReferencesTest { .value("value") .build() ) - .publicationWindows( - listOf( - References.Situation.PublicationWindow.builder() - .from(123L) - .to(123L) - .build() - ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder().from(0L).to(0L).build() ) .reason(References.Situation.Reason.EQUIPMENT_REASON) .severity("severity") @@ -271,24 +229,24 @@ class ReferencesTest { .containsExactly( References.Stop.builder() .id("id") - .lat(42.23) - .lon(42.23) + .lat(0.0) + .locationType(0L) + .lon(0.0) .name("name") .parent("parent") - .routeIds(listOf("string")) - .staticRouteIds(listOf("string")) + .addRouteId("string") + .addStaticRouteId("string") .code("code") .direction("direction") - .locationType(123L) .wheelchairBoarding("wheelchairBoarding") .build() ) assertThat(references.stopTimes()) .containsExactly( References.StopTime.builder() - .arrivalTime(123L) - .departureTime(123L) - .distanceAlongTrip(42.23) + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) .historicalOccupancy("historicalOccupancy") .stopHeadsign("stopHeadsign") .stopId("stopId") @@ -302,7 +260,7 @@ class ReferencesTest { .serviceId("serviceId") .blockId("blockId") .directionId("directionId") - .peakOffpeak(123L) + .peakOffpeak(0L) .routeShortName("routeShortName") .shapeId("shapeId") .timeZone("timeZone") @@ -311,4 +269,145 @@ class ReferencesTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val references = + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder().from(0L).to(0L).build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails.builder() + .diversionPath( + References.Situation.Consequence.ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder().from(0L).to(0L).build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url(References.Situation.Url.builder().lang("lang").value("value").build()) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + + val roundtrippedReferences = + jsonMapper.readValue( + jsonMapper.writeValueAsString(references), + jacksonTypeRef(), + ) + + assertThat(roundtrippedReferences).isEqualTo(references) + } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt deleted file mode 100644 index ca3f9e6..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class ReportProblemWithStopRetrieveParamsTest { - - @Test - fun createReportProblemWithStopRetrieveParams() { - ReportProblemWithStopRetrieveParams.builder() - .stopId("stopID") - .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) - .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) - .build() - } - - @Test - fun getQueryParams() { - val params = - ReportProblemWithStopRetrieveParams.builder() - .stopId("stopID") - .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) - .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) - .build() - val expected = mutableMapOf>() - expected.put( - "code", - listOf(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG.toString()) - ) - expected.put("userComment", listOf("userComment")) - expected.put("userLat", listOf("42.23")) - expected.put("userLocationAccuracy", listOf("42.23")) - expected.put("userLon", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = ReportProblemWithStopRetrieveParams.builder().stopId("stopID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = ReportProblemWithStopRetrieveParams.builder().stopId("stopID").build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt deleted file mode 100644 index 64ed4cc..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt +++ /dev/null @@ -1,77 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class ReportProblemWithTripRetrieveParamsTest { - - @Test - fun createReportProblemWithTripRetrieveParams() { - ReportProblemWithTripRetrieveParams.builder() - .tripId("tripID") - .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) - .serviceDate(123L) - .stopId("stopID") - .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) - .userOnVehicle(true) - .userVehicleNumber("userVehicleNumber") - .vehicleId("vehicleID") - .build() - } - - @Test - fun getQueryParams() { - val params = - ReportProblemWithTripRetrieveParams.builder() - .tripId("tripID") - .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) - .serviceDate(123L) - .stopId("stopID") - .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) - .userOnVehicle(true) - .userVehicleNumber("userVehicleNumber") - .vehicleId("vehicleID") - .build() - val expected = mutableMapOf>() - expected.put( - "code", - listOf(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME.toString()) - ) - expected.put("serviceDate", listOf("123")) - expected.put("stopID", listOf("stopID")) - expected.put("userComment", listOf("userComment")) - expected.put("userLat", listOf("42.23")) - expected.put("userLocationAccuracy", listOf("42.23")) - expected.put("userLon", listOf("42.23")) - expected.put("userOnVehicle", listOf("true")) - expected.put("userVehicleNumber", listOf("userVehicleNumber")) - expected.put("vehicleID", listOf("vehicleID")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = ReportProblemWithTripRetrieveParams.builder().tripId("tripID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = ReportProblemWithTripRetrieveParams.builder().tripId("tripID").build() - assertThat(params).isNotNull - // path param "tripId" - assertThat(params.getPathParam(0)).isEqualTo("tripID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt index c9dabeb..dbf3ef5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt @@ -2,24 +2,36 @@ package org.onebusaway.models +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper -class ResponseWrapperTest { +internal class ResponseWrapperTest { @Test - fun createResponseWrapper() { + fun create() { val responseWrapper = - ResponseWrapper.builder() - .code(123L) - .currentTime(123L) - .text("text") - .version(123L) - .build() - assertThat(responseWrapper).isNotNull - assertThat(responseWrapper.code()).isEqualTo(123L) - assertThat(responseWrapper.currentTime()).isEqualTo(123L) + 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(123L) + 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/RoutesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt deleted file mode 100644 index 798f270..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class RoutesForAgencyListParamsTest { - - @Test - fun createRoutesForAgencyListParams() { - RoutesForAgencyListParams.builder().agencyId("agencyID").build() - } - - @Test - fun getPathParam() { - val params = RoutesForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt deleted file mode 100644 index 946a91a..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class RoutesForLocationListParamsTest { - - @Test - fun createRoutesForLocationListParams() { - RoutesForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) - .query("query") - .radius(42.23) - .build() - } - - @Test - fun getQueryParams() { - val params = - RoutesForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) - .query("query") - .radius(42.23) - .build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("lon", listOf("42.23")) - expected.put("latSpan", listOf("42.23")) - expected.put("lonSpan", listOf("42.23")) - expected.put("query", listOf("query")) - expected.put("radius", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = RoutesForLocationListParams.builder().lat(42.23).lon(42.23).build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("lon", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt deleted file mode 100644 index 98f2520..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import java.time.LocalDate -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class ScheduleForRouteRetrieveParamsTest { - - @Test - fun createScheduleForRouteRetrieveParams() { - ScheduleForRouteRetrieveParams.builder() - .routeId("routeID") - .date(LocalDate.parse("2019-12-27")) - .build() - } - - @Test - fun getQueryParams() { - val params = - ScheduleForRouteRetrieveParams.builder() - .routeId("routeID") - .date(LocalDate.parse("2019-12-27")) - .build() - val expected = mutableMapOf>() - expected.put("date", listOf("2019-12-27")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = ScheduleForRouteRetrieveParams.builder().routeId("routeID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = ScheduleForRouteRetrieveParams.builder().routeId("routeID").build() - assertThat(params).isNotNull - // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("routeID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt deleted file mode 100644 index 1b2453d..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class SearchForRouteListParamsTest { - - @Test - fun createSearchForRouteListParams() { - SearchForRouteListParams.builder().input("input").maxCount(123L).build() - } - - @Test - fun getQueryParams() { - val params = SearchForRouteListParams.builder().input("input").maxCount(123L).build() - val expected = mutableMapOf>() - expected.put("input", listOf("input")) - expected.put("maxCount", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = SearchForRouteListParams.builder().input("input").build() - val expected = mutableMapOf>() - expected.put("input", listOf("input")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt deleted file mode 100644 index 1825b87..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class SearchForStopListParamsTest { - - @Test - fun createSearchForStopListParams() { - SearchForStopListParams.builder().input("input").maxCount(123L).build() - } - - @Test - fun getQueryParams() { - val params = SearchForStopListParams.builder().input("input").maxCount(123L).build() - val expected = mutableMapOf>() - expected.put("input", listOf("input")) - expected.put("maxCount", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = SearchForStopListParams.builder().input("input").build() - val expected = mutableMapOf>() - expected.put("input", listOf("input")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt deleted file mode 100644 index 07dde7e..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class StopsForLocationListParamsTest { - - @Test - fun createStopsForLocationListParams() { - StopsForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) - .query("query") - .radius(42.23) - .build() - } - - @Test - fun getQueryParams() { - val params = - StopsForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) - .query("query") - .radius(42.23) - .build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("lon", listOf("42.23")) - expected.put("latSpan", listOf("42.23")) - expected.put("lonSpan", listOf("42.23")) - expected.put("query", listOf("query")) - expected.put("radius", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = StopsForLocationListParams.builder().lat(42.23).lon(42.23).build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("lon", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt deleted file mode 100644 index 607e832..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class StopsForRouteListParamsTest { - - @Test - fun createStopsForRouteListParams() { - StopsForRouteListParams.builder() - .routeId("routeID") - .includePolylines(true) - .time("time") - .build() - } - - @Test - fun getQueryParams() { - val params = - StopsForRouteListParams.builder() - .routeId("routeID") - .includePolylines(true) - .time("time") - .build() - val expected = mutableMapOf>() - expected.put("includePolylines", listOf("true")) - expected.put("time", listOf("time")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = StopsForRouteListParams.builder().routeId("routeID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = StopsForRouteListParams.builder().routeId("routeID").build() - assertThat(params).isNotNull - // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("routeID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt deleted file mode 100644 index 2e4eaa9..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class TripDetailRetrieveParamsTest { - - @Test - fun createTripDetailRetrieveParams() { - TripDetailRetrieveParams.builder() - .tripId("tripID") - .includeSchedule(true) - .includeStatus(true) - .includeTrip(true) - .serviceDate(123L) - .time(123L) - .build() - } - - @Test - fun getQueryParams() { - val params = - TripDetailRetrieveParams.builder() - .tripId("tripID") - .includeSchedule(true) - .includeStatus(true) - .includeTrip(true) - .serviceDate(123L) - .time(123L) - .build() - val expected = mutableMapOf>() - expected.put("includeSchedule", listOf("true")) - expected.put("includeStatus", listOf("true")) - expected.put("includeTrip", listOf("true")) - expected.put("serviceDate", listOf("123")) - expected.put("time", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = TripDetailRetrieveParams.builder().tripId("tripID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = TripDetailRetrieveParams.builder().tripId("tripID").build() - assertThat(params).isNotNull - // path param "tripId" - assertThat(params.getPathParam(0)).isEqualTo("tripID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt deleted file mode 100644 index e30e5e3..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class TripForVehicleRetrieveParamsTest { - - @Test - fun createTripForVehicleRetrieveParams() { - TripForVehicleRetrieveParams.builder() - .vehicleId("vehicleID") - .includeSchedule(true) - .includeStatus(true) - .includeTrip(true) - .time(123L) - .build() - } - - @Test - fun getQueryParams() { - val params = - TripForVehicleRetrieveParams.builder() - .vehicleId("vehicleID") - .includeSchedule(true) - .includeStatus(true) - .includeTrip(true) - .time(123L) - .build() - val expected = mutableMapOf>() - expected.put("includeSchedule", listOf("true")) - expected.put("includeStatus", listOf("true")) - expected.put("includeTrip", listOf("true")) - expected.put("time", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = TripForVehicleRetrieveParams.builder().vehicleId("vehicleID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = TripForVehicleRetrieveParams.builder().vehicleId("vehicleID").build() - assertThat(params).isNotNull - // path param "vehicleId" - assertThat(params.getPathParam(0)).isEqualTo("vehicleID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt deleted file mode 100644 index e92df58..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class TripsForLocationListParamsTest { - - @Test - fun createTripsForLocationListParams() { - TripsForLocationListParams.builder() - .lat(42.23) - .latSpan(42.23) - .lon(42.23) - .lonSpan(42.23) - .includeSchedule(true) - .includeTrip(true) - .time(123L) - .build() - } - - @Test - fun getQueryParams() { - val params = - TripsForLocationListParams.builder() - .lat(42.23) - .latSpan(42.23) - .lon(42.23) - .lonSpan(42.23) - .includeSchedule(true) - .includeTrip(true) - .time(123L) - .build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("latSpan", listOf("42.23")) - expected.put("lon", listOf("42.23")) - expected.put("lonSpan", listOf("42.23")) - expected.put("includeSchedule", listOf("true")) - expected.put("includeTrip", listOf("true")) - expected.put("time", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = - TripsForLocationListParams.builder() - .lat(42.23) - .latSpan(42.23) - .lon(42.23) - .lonSpan(42.23) - .build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("latSpan", listOf("42.23")) - expected.put("lon", listOf("42.23")) - expected.put("lonSpan", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt deleted file mode 100644 index 6914198..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class TripsForRouteListParamsTest { - - @Test - fun createTripsForRouteListParams() { - TripsForRouteListParams.builder() - .routeId("routeID") - .includeSchedule(true) - .includeStatus(true) - .time(123L) - .build() - } - - @Test - fun getQueryParams() { - val params = - TripsForRouteListParams.builder() - .routeId("routeID") - .includeSchedule(true) - .includeStatus(true) - .time(123L) - .build() - val expected = mutableMapOf>() - expected.put("includeSchedule", listOf("true")) - expected.put("includeStatus", listOf("true")) - expected.put("time", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = TripsForRouteListParams.builder().routeId("routeID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = TripsForRouteListParams.builder().routeId("routeID").build() - assertThat(params).isNotNull - // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("routeID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt deleted file mode 100644 index 93762bd..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.models.* - -class VehiclesForAgencyListParamsTest { - - @Test - fun createVehiclesForAgencyListParams() { - VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() - } - - @Test - fun getQueryParams() { - val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() - val expected = mutableMapOf>() - expected.put("time", listOf("time")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getPathParam() { - val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt similarity index 52% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt index b9a2bd0..7879547 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt @@ -1,14 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.agencieswithcoverage import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class AgenciesWithCoverageListParamsTest { +internal class AgenciesWithCoverageListParamsTest { @Test - fun createAgenciesWithCoverageListParams() { + 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/AgencyRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveParamsTest.kt index ac27d2d..f3b777c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.agency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class AgencyRetrieveParamsTest { +internal class AgencyRetrieveParamsTest { @Test - fun createAgencyRetrieveParams() { + fun create() { AgencyRetrieveParams.builder().agencyId("agencyID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = AgencyRetrieveParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + + assertThat(params._pathParam(0)).isEqualTo("agencyID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt new file mode 100644 index 0000000..16fb9ac --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agency + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class AgencyRetrieveResponseTest { + + @Test + fun create() { + val agencyRetrieveResponse = + AgencyRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + AgencyRetrieveResponse.Data.builder() + .entry( + AgencyRetrieveResponse.Data.Entry.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .limitExceeded(true) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(agencyRetrieveResponse.code()).isEqualTo(0L) + assertThat(agencyRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(agencyRetrieveResponse.text()).isEqualTo("text") + assertThat(agencyRetrieveResponse.version()).isEqualTo(0L) + assertThat(agencyRetrieveResponse.data()) + .isEqualTo( + AgencyRetrieveResponse.Data.builder() + .entry( + AgencyRetrieveResponse.Data.Entry.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .limitExceeded(true) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val agencyRetrieveResponse = + AgencyRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + AgencyRetrieveResponse.Data.builder() + .entry( + AgencyRetrieveResponse.Data.Entry.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .limitExceeded(true) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedAgencyRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(agencyRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAgencyRetrieveResponse).isEqualTo(agencyRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/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/BlockRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveParamsTest.kt index ce5a695..f9bbb90 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.block import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class BlockRetrieveParamsTest { +internal class BlockRetrieveParamsTest { @Test - fun createBlockRetrieveParams() { + fun create() { BlockRetrieveParams.builder().blockId("blockID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = BlockRetrieveParams.builder().blockId("blockID").build() - assertThat(params).isNotNull - // path param "blockId" - assertThat(params.getPathParam(0)).isEqualTo("blockID") + + assertThat(params._pathParam(0)).isEqualTo("blockID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt new file mode 100644 index 0000000..c905c86 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt @@ -0,0 +1,617 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.block + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class BlockRetrieveResponseTest { + + @Test + fun create() { + val blockRetrieveResponse = + BlockRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + BlockRetrieveResponse.Data.builder() + .entry( + BlockRetrieveResponse.Data.Entry.builder() + .id("id") + .addConfiguration( + BlockRetrieveResponse.Data.Entry.Configuration.builder() + .addActiveServiceId("string") + .addTrip( + BlockRetrieveResponse.Data.Entry.Configuration.Trip + .builder() + .accumulatedSlackTime(0.0f) + .addBlockStopTime( + BlockRetrieveResponse.Data.Entry.Configuration + .Trip + .BlockStopTime + .builder() + .accumulatedSlackTime(0.0f) + .blockSequence(0L) + .distanceAlongBlock(0.0f) + .stopTime( + BlockRetrieveResponse.Data.Entry + .Configuration + .Trip + .BlockStopTime + .StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .stopId("stopId") + .dropOffType(0L) + .pickupType(0L) + .build() + ) + .build() + ) + .distanceAlongBlock(0.0f) + .tripId("tripId") + .build() + ) + .addInactiveServiceId("string") + .build() + ) + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(blockRetrieveResponse.code()).isEqualTo(0L) + assertThat(blockRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(blockRetrieveResponse.text()).isEqualTo("text") + assertThat(blockRetrieveResponse.version()).isEqualTo(0L) + assertThat(blockRetrieveResponse.data()) + .isEqualTo( + BlockRetrieveResponse.Data.builder() + .entry( + BlockRetrieveResponse.Data.Entry.builder() + .id("id") + .addConfiguration( + BlockRetrieveResponse.Data.Entry.Configuration.builder() + .addActiveServiceId("string") + .addTrip( + BlockRetrieveResponse.Data.Entry.Configuration.Trip + .builder() + .accumulatedSlackTime(0.0f) + .addBlockStopTime( + BlockRetrieveResponse.Data.Entry.Configuration.Trip + .BlockStopTime + .builder() + .accumulatedSlackTime(0.0f) + .blockSequence(0L) + .distanceAlongBlock(0.0f) + .stopTime( + BlockRetrieveResponse.Data.Entry + .Configuration + .Trip + .BlockStopTime + .StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .stopId("stopId") + .dropOffType(0L) + .pickupType(0L) + .build() + ) + .build() + ) + .distanceAlongBlock(0.0f) + .tripId("tripId") + .build() + ) + .addInactiveServiceId("string") + .build() + ) + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val blockRetrieveResponse = + BlockRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + BlockRetrieveResponse.Data.builder() + .entry( + BlockRetrieveResponse.Data.Entry.builder() + .id("id") + .addConfiguration( + BlockRetrieveResponse.Data.Entry.Configuration.builder() + .addActiveServiceId("string") + .addTrip( + BlockRetrieveResponse.Data.Entry.Configuration.Trip + .builder() + .accumulatedSlackTime(0.0f) + .addBlockStopTime( + BlockRetrieveResponse.Data.Entry.Configuration + .Trip + .BlockStopTime + .builder() + .accumulatedSlackTime(0.0f) + .blockSequence(0L) + .distanceAlongBlock(0.0f) + .stopTime( + BlockRetrieveResponse.Data.Entry + .Configuration + .Trip + .BlockStopTime + .StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .stopId("stopId") + .dropOffType(0L) + .pickupType(0L) + .build() + ) + .build() + ) + .distanceAlongBlock(0.0f) + .tripId("tripId") + .build() + ) + .addInactiveServiceId("string") + .build() + ) + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedBlockRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(blockRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBlockRetrieveResponse).isEqualTo(blockRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveParamsTest.kt similarity index 54% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveParamsTest.kt index 2a94f4c..e0e0be4 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveParamsTest.kt @@ -1,14 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.config import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class ConfigRetrieveParamsTest { +internal class ConfigRetrieveParamsTest { @Test - fun createConfigRetrieveParams() { + 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/CurrentTimeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParamsTest.kt similarity index 53% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParamsTest.kt index 673dba1..23e4299 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParamsTest.kt @@ -1,14 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.currenttime import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class CurrentTimeRetrieveParamsTest { +internal class CurrentTimeRetrieveParamsTest { @Test - fun createCurrentTimeRetrieveParams() { + 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/RouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt index 5af4c59..bbd2166 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.route import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class RouteRetrieveParamsTest { +internal class RouteRetrieveParamsTest { @Test - fun createRouteRetrieveParams() { + fun create() { RouteRetrieveParams.builder().routeId("routeID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = RouteRetrieveParams.builder().routeId("routeID").build() - assertThat(params).isNotNull - // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("routeID") + + assertThat(params._pathParam(0)).isEqualTo("routeID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt new file mode 100644 index 0000000..46f764f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt @@ -0,0 +1,531 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.route + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class RouteRetrieveResponseTest { + + @Test + fun create() { + val routeRetrieveResponse = + RouteRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RouteRetrieveResponse.Data.builder() + .entry( + RouteRetrieveResponse.Data.Entry.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(routeRetrieveResponse.code()).isEqualTo(0L) + assertThat(routeRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(routeRetrieveResponse.text()).isEqualTo("text") + assertThat(routeRetrieveResponse.version()).isEqualTo(0L) + assertThat(routeRetrieveResponse.data()) + .isEqualTo( + RouteRetrieveResponse.Data.builder() + .entry( + RouteRetrieveResponse.Data.Entry.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val routeRetrieveResponse = + RouteRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RouteRetrieveResponse.Data.builder() + .entry( + RouteRetrieveResponse.Data.Entry.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedRouteRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(routeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRouteRetrieveResponse).isEqualTo(routeRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParamsTest.kt index ade68cb..190f192 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.routeidsforagency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class RouteIdsForAgencyListParamsTest { +internal class RouteIdsForAgencyListParamsTest { @Test - fun createRouteIdsForAgencyListParams() { + fun create() { RouteIdsForAgencyListParams.builder().agencyId("agencyID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = RouteIdsForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + + assertThat(params._pathParam(0)).isEqualTo("agencyID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt new file mode 100644 index 0000000..09d6987 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt @@ -0,0 +1,496 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routeidsforagency + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class RouteIdsForAgencyListResponseTest { + + @Test + fun create() { + val routeIdsForAgencyListResponse = + RouteIdsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RouteIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(routeIdsForAgencyListResponse.code()).isEqualTo(0L) + assertThat(routeIdsForAgencyListResponse.currentTime()).isEqualTo(0L) + assertThat(routeIdsForAgencyListResponse.text()).isEqualTo("text") + assertThat(routeIdsForAgencyListResponse.version()).isEqualTo(0L) + assertThat(routeIdsForAgencyListResponse.data()) + .isEqualTo( + RouteIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val routeIdsForAgencyListResponse = + RouteIdsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RouteIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedRouteIdsForAgencyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(routeIdsForAgencyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRouteIdsForAgencyListResponse) + .isEqualTo(routeIdsForAgencyListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/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/ScheduleForStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt similarity index 51% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt index 645d47e..2be4584 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.scheduleforstop import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* +import org.onebusaway.core.http.QueryParams -class ScheduleForStopRetrieveParamsTest { +internal class ScheduleForStopRetrieveParamsTest { @Test - fun createScheduleForStopRetrieveParams() { + fun create() { ScheduleForStopRetrieveParams.builder() .stopId("stopID") .date(LocalDate.parse("2019-12-27")) @@ -18,31 +18,33 @@ class ScheduleForStopRetrieveParamsTest { } @Test - fun getQueryParams() { + 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 expected = mutableMapOf>() - expected.put("date", listOf("2019-12-27")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = ScheduleForStopRetrieveParams.builder().stopId("stopID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("date", "2019-12-27").build()) } @Test - fun getPathParam() { + fun queryParamsWithoutOptionalFields() { val params = ScheduleForStopRetrieveParams.builder().stopId("stopID").build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt new file mode 100644 index 0000000..6a1cef0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt @@ -0,0 +1,636 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforstop + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class ScheduleForStopRetrieveResponseTest { + + @Test + fun create() { + val scheduleForStopRetrieveResponse = + ScheduleForStopRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ScheduleForStopRetrieveResponse.Data.builder() + .entry( + ScheduleForStopRetrieveResponse.Data.Entry.builder() + .date(0L) + .stopId("stopId") + .addStopRouteSchedule( + ScheduleForStopRetrieveResponse.Data.Entry.StopRouteSchedule + .builder() + .routeId("routeId") + .addStopRouteDirectionSchedule( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .builder() + .addScheduleStopTime( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleStopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .serviceId("serviceId") + .tripId("tripId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripHeadsign("tripHeadsign") + .addScheduleFrequency( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleFrequency + .builder() + .endTime(0L) + .headway(0) + .serviceDate(0L) + .serviceId("serviceId") + .startTime(0L) + .tripId("tripId") + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(scheduleForStopRetrieveResponse.code()).isEqualTo(0L) + assertThat(scheduleForStopRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(scheduleForStopRetrieveResponse.text()).isEqualTo("text") + assertThat(scheduleForStopRetrieveResponse.version()).isEqualTo(0L) + assertThat(scheduleForStopRetrieveResponse.data()) + .isEqualTo( + ScheduleForStopRetrieveResponse.Data.builder() + .entry( + ScheduleForStopRetrieveResponse.Data.Entry.builder() + .date(0L) + .stopId("stopId") + .addStopRouteSchedule( + ScheduleForStopRetrieveResponse.Data.Entry.StopRouteSchedule + .builder() + .routeId("routeId") + .addStopRouteDirectionSchedule( + ScheduleForStopRetrieveResponse.Data.Entry.StopRouteSchedule + .StopRouteDirectionSchedule + .builder() + .addScheduleStopTime( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleStopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .serviceId("serviceId") + .tripId("tripId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripHeadsign("tripHeadsign") + .addScheduleFrequency( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleFrequency + .builder() + .endTime(0L) + .headway(0) + .serviceDate(0L) + .serviceId("serviceId") + .startTime(0L) + .tripId("tripId") + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val scheduleForStopRetrieveResponse = + ScheduleForStopRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ScheduleForStopRetrieveResponse.Data.builder() + .entry( + ScheduleForStopRetrieveResponse.Data.Entry.builder() + .date(0L) + .stopId("stopId") + .addStopRouteSchedule( + ScheduleForStopRetrieveResponse.Data.Entry.StopRouteSchedule + .builder() + .routeId("routeId") + .addStopRouteDirectionSchedule( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .builder() + .addScheduleStopTime( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleStopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .serviceId("serviceId") + .tripId("tripId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripHeadsign("tripHeadsign") + .addScheduleFrequency( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleFrequency + .builder() + .endTime(0L) + .headway(0) + .serviceDate(0L) + .serviceId("serviceId") + .startTime(0L) + .tripId("tripId") + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedScheduleForStopRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(scheduleForStopRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedScheduleForStopRetrieveResponse) + .isEqualTo(scheduleForStopRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/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/ShapeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveParamsTest.kt index 41e8572..2300caf 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.shape import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class ShapeRetrieveParamsTest { +internal class ShapeRetrieveParamsTest { @Test - fun createShapeRetrieveParams() { + fun create() { ShapeRetrieveParams.builder().shapeId("shapeID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = ShapeRetrieveParams.builder().shapeId("shapeID").build() - assertThat(params).isNotNull - // path param "shapeId" - assertThat(params.getPathParam(0)).isEqualTo("shapeID") + + assertThat(params._pathParam(0)).isEqualTo("shapeID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt new file mode 100644 index 0000000..cbd2651 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt @@ -0,0 +1,510 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.shape + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class ShapeRetrieveResponseTest { + + @Test + fun create() { + val shapeRetrieveResponse = + ShapeRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ShapeRetrieveResponse.Data.builder() + .entry( + ShapeRetrieveResponse.Data.Entry.builder() + .length(0L) + .points("points") + .levels("levels") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(shapeRetrieveResponse.code()).isEqualTo(0L) + assertThat(shapeRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(shapeRetrieveResponse.text()).isEqualTo("text") + assertThat(shapeRetrieveResponse.version()).isEqualTo(0L) + assertThat(shapeRetrieveResponse.data()) + .isEqualTo( + ShapeRetrieveResponse.Data.builder() + .entry( + ShapeRetrieveResponse.Data.Entry.builder() + .length(0L) + .points("points") + .levels("levels") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val shapeRetrieveResponse = + ShapeRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ShapeRetrieveResponse.Data.builder() + .entry( + ShapeRetrieveResponse.Data.Entry.builder() + .length(0L) + .points("points") + .levels("levels") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedShapeRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(shapeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedShapeRetrieveResponse).isEqualTo(shapeRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveParamsTest.kt index 7fa9cd9..60c24a1 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stop import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class StopRetrieveParamsTest { +internal class StopRetrieveParamsTest { @Test - fun createStopRetrieveParams() { + fun create() { StopRetrieveParams.builder().stopId("stopID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = StopRetrieveParams.builder().stopId("stopID").build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") + + assertThat(params._pathParam(0)).isEqualTo("stopID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt new file mode 100644 index 0000000..9120c5f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stop + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class StopRetrieveResponseTest { + + @Test + fun create() { + val stopRetrieveResponse = + StopRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopRetrieveResponse.Data.builder() + .entry( + StopRetrieveResponse.Data.Entry.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(stopRetrieveResponse.code()).isEqualTo(0L) + assertThat(stopRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(stopRetrieveResponse.text()).isEqualTo("text") + assertThat(stopRetrieveResponse.version()).isEqualTo(0L) + assertThat(stopRetrieveResponse.data()) + .isEqualTo( + StopRetrieveResponse.Data.builder() + .entry( + StopRetrieveResponse.Data.Entry.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stopRetrieveResponse = + StopRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopRetrieveResponse.Data.builder() + .entry( + StopRetrieveResponse.Data.Entry.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedStopRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stopRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStopRetrieveResponse).isEqualTo(stopRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParamsTest.kt index f87b32a..c0f8cfc 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopidsforagency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class StopIdsForAgencyListParamsTest { +internal class StopIdsForAgencyListParamsTest { @Test - fun createStopIdsForAgencyListParams() { + fun create() { StopIdsForAgencyListParams.builder().agencyId("agencyID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = StopIdsForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + + assertThat(params._pathParam(0)).isEqualTo("agencyID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt new file mode 100644 index 0000000..f11d550 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt @@ -0,0 +1,495 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopidsforagency + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class StopIdsForAgencyListResponseTest { + + @Test + fun create() { + val stopIdsForAgencyListResponse = + StopIdsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(stopIdsForAgencyListResponse.code()).isEqualTo(0L) + assertThat(stopIdsForAgencyListResponse.currentTime()).isEqualTo(0L) + assertThat(stopIdsForAgencyListResponse.text()).isEqualTo("text") + assertThat(stopIdsForAgencyListResponse.version()).isEqualTo(0L) + assertThat(stopIdsForAgencyListResponse.data()) + .isEqualTo( + StopIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stopIdsForAgencyListResponse = + StopIdsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedStopIdsForAgencyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stopIdsForAgencyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStopIdsForAgencyListResponse).isEqualTo(stopIdsForAgencyListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParamsTest.kt index 4559d12..aa6e543 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopsforagency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class StopsForAgencyListParamsTest { +internal class StopsForAgencyListParamsTest { @Test - fun createStopsForAgencyListParams() { + fun create() { StopsForAgencyListParams.builder().agencyId("agencyID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = StopsForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + + assertThat(params._pathParam(0)).isEqualTo("agencyID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt new file mode 100644 index 0000000..29422fd --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt @@ -0,0 +1,522 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforagency + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class StopsForAgencyListResponseTest { + + @Test + fun create() { + val stopsForAgencyListResponse = + StopsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .limitExceeded(true) + .addList( + StopsForAgencyListResponse.List.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .outOfRange(true) + .build() + + assertThat(stopsForAgencyListResponse.code()).isEqualTo(0L) + assertThat(stopsForAgencyListResponse.currentTime()).isEqualTo(0L) + assertThat(stopsForAgencyListResponse.text()).isEqualTo("text") + assertThat(stopsForAgencyListResponse.version()).isEqualTo(0L) + assertThat(stopsForAgencyListResponse.limitExceeded()).isEqualTo(true) + assertThat(stopsForAgencyListResponse.list()) + .containsExactly( + StopsForAgencyListResponse.List.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + assertThat(stopsForAgencyListResponse.references()) + .isEqualTo( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder().from(0L).to(0L).build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails.builder() + .diversionPath( + References.Situation.Consequence.ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + assertThat(stopsForAgencyListResponse.outOfRange()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stopsForAgencyListResponse = + StopsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .limitExceeded(true) + .addList( + StopsForAgencyListResponse.List.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .outOfRange(true) + .build() + + val roundtrippedStopsForAgencyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stopsForAgencyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStopsForAgencyListResponse).isEqualTo(stopsForAgencyListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/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/TripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveParamsTest.kt index 61d3ab0..fc93c04 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveParamsTest.kt @@ -1,25 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.trip import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* -class TripRetrieveParamsTest { +internal class TripRetrieveParamsTest { @Test - fun createTripRetrieveParams() { + fun create() { TripRetrieveParams.builder().tripId("tripID").build() } @Test - fun getPathParam() { + fun pathParams() { val params = TripRetrieveParams.builder().tripId("tripID").build() - assertThat(params).isNotNull - // path param "tripId" - assertThat(params.getPathParam(0)).isEqualTo("tripID") + + assertThat(params._pathParam(0)).isEqualTo("tripID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt new file mode 100644 index 0000000..0886e40 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.trip + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class TripRetrieveResponseTest { + + @Test + fun create() { + val tripRetrieveResponse = + TripRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripRetrieveResponse.Data.builder() + .entry( + TripRetrieveResponse.Data.Entry.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(tripRetrieveResponse.code()).isEqualTo(0L) + assertThat(tripRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(tripRetrieveResponse.text()).isEqualTo("text") + assertThat(tripRetrieveResponse.version()).isEqualTo(0L) + assertThat(tripRetrieveResponse.data()) + .isEqualTo( + TripRetrieveResponse.Data.builder() + .entry( + TripRetrieveResponse.Data.Entry.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tripRetrieveResponse = + TripRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripRetrieveResponse.Data.builder() + .entry( + TripRetrieveResponse.Data.Entry.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedTripRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tripRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTripRetrieveResponse).isEqualTo(tripRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/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 index 04f50bf..40931f5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt @@ -2,45 +2,49 @@ package org.onebusaway.services -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.get -import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import com.google.common.collect.ImmutableListMultimap -import com.google.common.collect.ListMultimap import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatThrownBy -import org.assertj.core.api.InstanceOfAssertFactories -import org.assertj.guava.api.Assertions.assertThat +import org.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.JsonString +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.OnebusawaySdkError import org.onebusaway.errors.OnebusawaySdkException import org.onebusaway.errors.PermissionDeniedException import org.onebusaway.errors.RateLimitException import org.onebusaway.errors.UnauthorizedException import org.onebusaway.errors.UnexpectedStatusCodeException import org.onebusaway.errors.UnprocessableEntityException -import org.onebusaway.models.* @WireMockTest -class ErrorHandlingTest { +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ErrorHandlingTest { - private val JSON_MAPPER: JsonMapper = jsonMapper() + companion object { - private val ONEBUSAWAY_SDK_ERROR: OnebusawaySdkError = - OnebusawaySdkError.builder().putAdditionalProperty("key", JsonString.of("value")).build() + private val ERROR_JSON: JsonValue = JsonValue.from(mapOf("errorProperty" to "42")) + + private val ERROR_JSON_BYTES: ByteArray = jsonMapper().writeValueAsBytes(ERROR_JSON) + + private const val HEADER_NAME: String = "Error-Header" + + private const val HEADER_VALUE: String = "42" + + private const val NOT_JSON: String = "Not JSON" + } private lateinit var client: OnebusawaySdkClient @@ -48,325 +52,162 @@ class ErrorHandlingTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = OnebusawaySdkOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") .build() } @Test - fun currentTimesRetrieve200() { - val params = CurrentTimeRetrieveParams.builder().build() - - val expected = CurrentTimeRetrieveResponse.builder().build() - - stubFor(get(anyUrl()).willReturn(ok().withBody(toJson(expected)))) - - assertThat(client.currentTime().retrieve(params)).isEqualTo(expected) - } - - @Test - fun currentTimesRetrieve400() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve400() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(400).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertBadRequest(e, ImmutableListMultimap.of("Foo", "Bar"), ONEBUSAWAY_SDK_ERROR) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve401() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve401() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(401).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertUnauthorized(e, ImmutableListMultimap.of("Foo", "Bar"), ONEBUSAWAY_SDK_ERROR) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve403() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve403() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(403).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertPermissionDenied( - e, - ImmutableListMultimap.of("Foo", "Bar"), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve404() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve404() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(404).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertNotFound(e, ImmutableListMultimap.of("Foo", "Bar"), ONEBUSAWAY_SDK_ERROR) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve422() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve422() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(422).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertUnprocessableEntity( - e, - ImmutableListMultimap.of("Foo", "Bar"), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve429() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve429() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(429).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertRateLimit(e, ImmutableListMultimap.of("Foo", "Bar"), ONEBUSAWAY_SDK_ERROR) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve500() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve500() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(500).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertInternalServer( - e, - ImmutableListMultimap.of("Foo", "Bar"), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun unexpectedStatusCode() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve999() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(999).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertUnexpectedStatusCodeException( - e, - 999, - ImmutableListMultimap.of("Foo", "Bar"), - toJson(ONEBUSAWAY_SDK_ERROR) - ) - }) - } + val e = assertThrows { currentTimeService.retrieve() } - @Test - fun invalidBody() { - val params = CurrentTimeRetrieveParams.builder().build() - - stubFor(get(anyUrl()).willReturn(status(200).withBody("Not JSON"))) - - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertThat(e) - .isInstanceOf(OnebusawaySdkException::class.java) - .hasMessage("Error reading response") - }) + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun invalidErrorBody() { - val params = CurrentTimeRetrieveParams.builder().build() - - stubFor(get(anyUrl()).willReturn(status(400).withBody("Not JSON"))) - - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertBadRequest( - e, - ImmutableListMultimap.of(), - OnebusawaySdkError.builder().build() - ) - }) - } - - private fun toJson(body: T): ByteArray { - return JSON_MAPPER.writeValueAsBytes(body) - } - - private fun assertUnexpectedStatusCodeException( - throwable: Throwable, - statusCode: Int, - headers: ListMultimap, - responseBody: ByteArray - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnexpectedStatusCodeException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(statusCode) - assertThat(e.body()).isEqualTo(String(responseBody)) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) - } - - private fun assertBadRequest( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(BadRequestException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) - } - - private fun assertUnauthorized( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(UnauthorizedException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) - } - - private fun assertPermissionDenied( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(PermissionDeniedException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) - } - - private fun assertNotFound( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) - } + fun currentTimeRetrieveInvalidJsonBody() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) - private fun assertUnprocessableEntity( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnprocessableEntityException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) - } + val e = assertThrows { currentTimeService.retrieve() } - private fun assertRateLimit( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + assertThat(e).hasMessage("Error reading response") } - private fun assertInternalServer( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(InternalServerException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) - } + 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 index 519ab15..3b0ccc7 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt @@ -2,28 +2,25 @@ package org.onebusaway.services -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor import com.github.tomakehurst.wiremock.client.WireMock.ok -import com.github.tomakehurst.wiremock.client.WireMock.put import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.core.jsonMapper -import org.onebusaway.models.* +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams @WireMockTest -class ServiceParamsTest { - - private val JSON_MAPPER: JsonMapper = jsonMapper() +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ServiceParamsTest { private lateinit var client: OnebusawaySdkClient @@ -31,38 +28,27 @@ class ServiceParamsTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = OnebusawaySdkOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) .build() } @Test - fun currentTimesRetrieveWithAdditionalParams() { - val additionalHeaders = mutableMapOf>() - - additionalHeaders.put("x-test-header", listOf("abc1234")) - - val additionalQueryParams = mutableMapOf>() - - additionalQueryParams.put("test_query_param", listOf("def567")) + fun retrieve() { + val currentTimeService = client.currentTime() + stubFor(get(anyUrl()).willReturn(ok("{}"))) - val params = + currentTimeService.retrieve( CurrentTimeRetrieveParams.builder() - .additionalHeaders(additionalHeaders) - .additionalQueryParams(additionalQueryParams) + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") .build() - - val apiResponse = CurrentTimeRetrieveResponse.builder().build() - - stubFor( - get(anyUrl()) - .withHeader("x-test-header", equalTo("abc1234")) - .withQueryParam("test_query_param", equalTo("def567")) - .willReturn(ok(JSON_MAPPER.writeValueAsString(apiResponse))) ) - client.currentTime().retrieve(params) - - verify(getRequestedFor(anyUrl())) + verify( + getRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + ) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncTest.kt new file mode 100644 index 0000000..ab52483 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class AgenciesWithCoverageServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val agenciesWithCoverageServiceAsync = client.agenciesWithCoverage() + + val agenciesWithCoveragesFuture = agenciesWithCoverageServiceAsync.list() + + val agenciesWithCoverages = agenciesWithCoveragesFuture.get() + agenciesWithCoverages.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgencyServiceAsyncTest.kt new file mode 100644 index 0000000..ca796c7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class AgencyServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val agencyServiceAsync = client.agency() + + val agencyFuture = agencyServiceAsync.retrieve("agencyID") + + val agency = agencyFuture.get() + agency.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncTest.kt new file mode 100644 index 0000000..88ee5d0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ArrivalAndDepartureServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val arrivalAndDepartureServiceAsync = client.arrivalAndDeparture() + + val arrivalAndDepartureFuture = + arrivalAndDepartureServiceAsync.retrieve( + ArrivalAndDepartureRetrieveParams.builder() + .stopId("1_75403") + .serviceDate(0L) + .tripId("tripId") + .stopSequence(0L) + .time(0L) + .vehicleId("vehicleId") + .build() + ) + + val arrivalAndDeparture = arrivalAndDepartureFuture.get() + arrivalAndDeparture.validate() + } + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val arrivalAndDepartureServiceAsync = client.arrivalAndDeparture() + + val arrivalAndDeparturesFuture = + arrivalAndDepartureServiceAsync.list( + ArrivalAndDepartureListParams.builder() + .stopId("1_75403") + .minutesAfter(0L) + .minutesBefore(0L) + .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val arrivalAndDepartures = arrivalAndDeparturesFuture.get() + arrivalAndDepartures.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/BlockServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/BlockServiceAsyncTest.kt new file mode 100644 index 0000000..f738843 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/BlockServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class BlockServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val blockServiceAsync = client.block() + + val blockFuture = blockServiceAsync.retrieve("blockID") + + val block = blockFuture.get() + block.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ConfigServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ConfigServiceAsyncTest.kt new file mode 100644 index 0000000..4278265 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ConfigServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class ConfigServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val configServiceAsync = client.config() + + val configFuture = configServiceAsync.retrieve() + + val config = configFuture.get() + config.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncTest.kt new file mode 100644 index 0000000..c79a952 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class CurrentTimeServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val currentTimeServiceAsync = client.currentTime() + + val currentTimeFuture = currentTimeServiceAsync.retrieve() + + val currentTime = currentTimeFuture.get() + currentTime.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncTest.kt new file mode 100644 index 0000000..f8ae311 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ReportProblemWithStopServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val reportProblemWithStopServiceAsync = client.reportProblemWithStop() + + val responseWrapperFuture = + reportProblemWithStopServiceAsync.retrieve( + ReportProblemWithStopRetrieveParams.builder() + .stopId("stopID") + .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) + .userComment("userComment") + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) + .build() + ) + + val responseWrapper = responseWrapperFuture.get() + responseWrapper.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncTest.kt new file mode 100644 index 0000000..ba06e6a --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ReportProblemWithTripServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val reportProblemWithTripServiceAsync = client.reportProblemWithTrip() + + val responseWrapperFuture = + reportProblemWithTripServiceAsync.retrieve( + ReportProblemWithTripRetrieveParams.builder() + .tripId("tripID") + .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) + .serviceDate(0L) + .stopId("stopID") + .userComment("userComment") + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) + .userOnVehicle(true) + .userVehicleNumber("userVehicleNumber") + .vehicleId("vehicleID") + .build() + ) + + val responseWrapper = responseWrapperFuture.get() + responseWrapper.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..a075e7d --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class RouteIdsForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routeIdsForAgencyServiceAsync = client.routeIdsForAgency() + + val routeIdsForAgenciesFuture = routeIdsForAgencyServiceAsync.list("agencyID") + + val routeIdsForAgencies = routeIdsForAgenciesFuture.get() + routeIdsForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteServiceAsyncTest.kt new file mode 100644 index 0000000..c4658cb --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class RouteServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routeServiceAsync = client.route() + + val routeFuture = routeServiceAsync.retrieve("routeID") + + val route = routeFuture.get() + route.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..9c31691 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class RoutesForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routesForAgencyServiceAsync = client.routesForAgency() + + val routesForAgenciesFuture = routesForAgencyServiceAsync.list("40") + + val routesForAgencies = routesForAgenciesFuture.get() + routesForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncTest.kt new file mode 100644 index 0000000..c1ef31c --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class RoutesForLocationServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routesForLocationServiceAsync = client.routesForLocation() + + val routesForLocationsFuture = + routesForLocationServiceAsync.list( + RoutesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .build() + ) + + val routesForLocations = routesForLocationsFuture.get() + routesForLocations.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncTest.kt new file mode 100644 index 0000000..9774596 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ScheduleForRouteServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val scheduleForRouteServiceAsync = client.scheduleForRoute() + + val scheduleForRouteFuture = + scheduleForRouteServiceAsync.retrieve( + ScheduleForRouteRetrieveParams.builder() + .routeId("1_100223") + .date(LocalDate.parse("2019-12-27")) + .build() + ) + + val scheduleForRoute = scheduleForRouteFuture.get() + scheduleForRoute.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncTest.kt new file mode 100644 index 0000000..eb498fe --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ScheduleForStopServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val scheduleForStopServiceAsync = client.scheduleForStop() + + val scheduleForStopFuture = + scheduleForStopServiceAsync.retrieve( + ScheduleForStopRetrieveParams.builder() + .stopId("stopID") + .date(LocalDate.parse("2019-12-27")) + .build() + ) + + val scheduleForStop = scheduleForStopFuture.get() + scheduleForStop.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncTest.kt new file mode 100644 index 0000000..8003d54 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.searchforroute.SearchForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class SearchForRouteServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val searchForRouteServiceAsync = client.searchForRoute() + + val searchForRoutesFuture = + searchForRouteServiceAsync.list( + SearchForRouteListParams.builder().input("input").maxCount(0L).build() + ) + + val searchForRoutes = searchForRoutesFuture.get() + searchForRoutes.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncTest.kt new file mode 100644 index 0000000..22a892f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.searchforstop.SearchForStopListParams + +@ExtendWith(TestServerExtension::class) +internal class SearchForStopServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val searchForStopServiceAsync = client.searchForStop() + + val searchForStopsFuture = + searchForStopServiceAsync.list( + SearchForStopListParams.builder().input("input").maxCount(0L).build() + ) + + val searchForStops = searchForStopsFuture.get() + searchForStops.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ShapeServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ShapeServiceAsyncTest.kt new file mode 100644 index 0000000..fdd7f7f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ShapeServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class ShapeServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val shapeServiceAsync = client.shape() + + val shapeFuture = shapeServiceAsync.retrieve("shapeID") + + val shape = shapeFuture.get() + shape.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..a5e4bc1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class StopIdsForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopIdsForAgencyServiceAsync = client.stopIdsForAgency() + + val stopIdsForAgenciesFuture = stopIdsForAgencyServiceAsync.list("agencyID") + + val stopIdsForAgencies = stopIdsForAgenciesFuture.get() + stopIdsForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopServiceAsyncTest.kt new file mode 100644 index 0000000..4f96081 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class StopServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopServiceAsync = client.stop() + + val stopFuture = stopServiceAsync.retrieve("stopID") + + val stop = stopFuture.get() + stop.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..d23e9f6 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class StopsForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForAgencyServiceAsync = client.stopsForAgency() + + val stopsForAgenciesFuture = stopsForAgencyServiceAsync.list("agencyID") + + val stopsForAgencies = stopsForAgenciesFuture.get() + stopsForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncTest.kt new file mode 100644 index 0000000..9af0137 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class StopsForLocationServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForLocationServiceAsync = client.stopsForLocation() + + val stopsForLocationsFuture = + stopsForLocationServiceAsync.list( + StopsForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .build() + ) + + val stopsForLocations = stopsForLocationsFuture.get() + stopsForLocations.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncTest.kt new file mode 100644 index 0000000..f659ea4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.stopsforroute.StopsForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class StopsForRouteServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForRouteServiceAsync = client.stopsForRoute() + + val stopsForRoutesFuture = + stopsForRouteServiceAsync.list( + StopsForRouteListParams.builder() + .routeId("routeID") + .includePolylines(true) + .time("time") + .build() + ) + + val stopsForRoutes = stopsForRoutesFuture.get() + stopsForRoutes.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncTest.kt new file mode 100644 index 0000000..28e9c20 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class TripDetailServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripDetailServiceAsync = client.tripDetails() + + val tripDetailFuture = + tripDetailServiceAsync.retrieve( + TripDetailRetrieveParams.builder() + .tripId("tripID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .serviceDate(0L) + .time(0L) + .build() + ) + + val tripDetail = tripDetailFuture.get() + tripDetail.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncTest.kt new file mode 100644 index 0000000..7069748 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class TripForVehicleServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripForVehicleServiceAsync = client.tripForVehicle() + + val tripForVehicleFuture = + tripForVehicleServiceAsync.retrieve( + TripForVehicleRetrieveParams.builder() + .vehicleId("vehicleID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .time(0L) + .build() + ) + + val tripForVehicle = tripForVehicleFuture.get() + tripForVehicle.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripServiceAsyncTest.kt new file mode 100644 index 0000000..d223e77 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync + +@ExtendWith(TestServerExtension::class) +internal class TripServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripServiceAsync = client.trip() + + val tripFuture = tripServiceAsync.retrieve("tripID") + + val trip = tripFuture.get() + trip.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncTest.kt new file mode 100644 index 0000000..debd1d8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class TripsForLocationServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripsForLocationServiceAsync = client.tripsForLocation() + + val tripsForLocationsFuture = + tripsForLocationServiceAsync.list( + TripsForLocationListParams.builder() + .lat(0.0f) + .latSpan(0.0f) + .lon(0.0f) + .lonSpan(0.0f) + .includeSchedule(true) + .includeTrip(true) + .time(0L) + .build() + ) + + val tripsForLocations = tripsForLocationsFuture.get() + tripsForLocations.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncTest.kt new file mode 100644 index 0000000..f9241a5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.tripsforroute.TripsForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class TripsForRouteServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripsForRouteServiceAsync = client.tripsForRoute() + + val tripsForRoutesFuture = + tripsForRouteServiceAsync.list( + TripsForRouteListParams.builder() + .routeId("routeID") + .includeSchedule(true) + .includeStatus(true) + .time(0L) + .build() + ) + + val tripsForRoutes = tripsForRoutesFuture.get() + tripsForRoutes.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..5860ee8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams + +@ExtendWith(TestServerExtension::class) +internal class VehiclesForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val vehiclesForAgencyServiceAsync = client.vehiclesForAgency() + + val vehiclesForAgenciesFuture = + vehiclesForAgencyServiceAsync.list( + VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() + ) + + val vehiclesForAgencies = vehiclesForAgenciesFuture.get() + vehiclesForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt index 7b094a1..2970c2b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt @@ -6,21 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class AgenciesWithCoverageServiceTest { +internal class AgenciesWithCoverageServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val agenciesWithCoverageService = client.agenciesWithCoverage() - val agenciesWithCoverageListResponse = - agenciesWithCoverageService.list(AgenciesWithCoverageListParams.builder().build()) - println(agenciesWithCoverageListResponse) + + val agenciesWithCoverages = agenciesWithCoverageService.list() + + agenciesWithCoverages.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt index 0572732..3d53110 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt @@ -6,21 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class AgencyServiceTest { +internal class AgencyServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val agencyService = client.agency() - val agencyRetrieveResponse = - agencyService.retrieve(AgencyRetrieveParams.builder().agencyId("agencyID").build()) - println(agencyRetrieveResponse) + + val agency = agencyService.retrieve("agencyID") + + agency.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt index 8e0a8ee..3aac305 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt @@ -7,50 +7,55 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams @ExtendWith(TestServerExtension::class) -class ArrivalAndDepartureServiceTest { +internal class ArrivalAndDepartureServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val arrivalAndDepartureService = client.arrivalAndDeparture() - val arrivalAndDepartureRetrieveResponse = + + val arrivalAndDeparture = arrivalAndDepartureService.retrieve( ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") - .serviceDate(123L) + .stopId("1_75403") + .serviceDate(0L) .tripId("tripId") - .stopSequence(123L) - .time(123L) + .stopSequence(0L) + .time(0L) .vehicleId("vehicleId") .build() ) - println(arrivalAndDepartureRetrieveResponse) + + arrivalAndDeparture.validate() } @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val arrivalAndDepartureService = client.arrivalAndDeparture() - val arrivalAndDepartureListResponse = + + val arrivalAndDepartures = arrivalAndDepartureService.list( ArrivalAndDepartureListParams.builder() - .stopId("stopID") - .minutesAfter(123L) - .minutesBefore(123L) + .stopId("1_75403") + .minutesAfter(0L) + .minutesBefore(0L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - println(arrivalAndDepartureListResponse) + + arrivalAndDepartures.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt index f6f35a3..0d6577c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt @@ -6,21 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class BlockServiceTest { +internal class BlockServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val blockService = client.block() - val blockRetrieveResponse = - blockService.retrieve(BlockRetrieveParams.builder().blockId("blockID").build()) - println(blockRetrieveResponse) + + val block = blockService.retrieve("blockID") + + block.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt index bc5911c..44a28ec 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt @@ -6,20 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class ConfigServiceTest { +internal class ConfigServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val configService = client.config() - val configRetrieveResponse = configService.retrieve(ConfigRetrieveParams.builder().build()) - println(configRetrieveResponse) + + val config = configService.retrieve() + + config.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt index cdb4072..65d5853 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt @@ -6,21 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class CurrentTimeServiceTest { +internal class CurrentTimeServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val currentTimeService = client.currentTime() - val currentTimeRetrieveResponse = - currentTimeService.retrieve(CurrentTimeRetrieveParams.builder().build()) - println(currentTimeRetrieveResponse) + + val currentTime = currentTimeService.retrieve() + + currentTime.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt index c736e3d..b4e46ca 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt @@ -6,31 +6,32 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams @ExtendWith(TestServerExtension::class) -class ReportProblemWithStopServiceTest { +internal class ReportProblemWithStopServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val reportProblemWithStopService = client.reportProblemWithStop() + val responseWrapper = reportProblemWithStopService.retrieve( ReportProblemWithStopRetrieveParams.builder() .stopId("stopID") .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) .build() ) - println(responseWrapper) + responseWrapper.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt index cef72e1..057847d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt @@ -6,36 +6,37 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams @ExtendWith(TestServerExtension::class) -class ReportProblemWithTripServiceTest { +internal class ReportProblemWithTripServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val reportProblemWithTripService = client.reportProblemWithTrip() + val responseWrapper = reportProblemWithTripService.retrieve( ReportProblemWithTripRetrieveParams.builder() .tripId("tripID") .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) - .serviceDate(123L) + .serviceDate(0L) .stopId("stopID") .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) .userOnVehicle(true) .userVehicleNumber("userVehicleNumber") .vehicleId("vehicleID") .build() ) - println(responseWrapper) + responseWrapper.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt index c3a7118..bafe347 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt @@ -6,23 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class RouteIdsForAgencyServiceTest { +internal class RouteIdsForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val routeIdsForAgencyService = client.routeIdsForAgency() - val routeIdsForAgencyListResponse = - routeIdsForAgencyService.list( - RouteIdsForAgencyListParams.builder().agencyId("agencyID").build() - ) - println(routeIdsForAgencyListResponse) + + val routeIdsForAgencies = routeIdsForAgencyService.list("agencyID") + + routeIdsForAgencies.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt index 4047e42..38e8475 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt @@ -6,21 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class RouteServiceTest { +internal class RouteServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val routeService = client.route() - val routeRetrieveResponse = - routeService.retrieve(RouteRetrieveParams.builder().routeId("routeID").build()) - println(routeRetrieveResponse) + + val route = routeService.retrieve("routeID") + + route.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt index 4171539..2972560 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt @@ -6,23 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class RoutesForAgencyServiceTest { +internal class RoutesForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val routesForAgencyService = client.routesForAgency() - val routesForAgencyListResponse = - routesForAgencyService.list( - RoutesForAgencyListParams.builder().agencyId("agencyID").build() - ) - println(routesForAgencyListResponse) + + val routesForAgencies = routesForAgencyService.list("40") + + routesForAgencies.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt index be1c92e..376eeee 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt @@ -6,30 +6,32 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams @ExtendWith(TestServerExtension::class) -class RoutesForLocationServiceTest { +internal class RoutesForLocationServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val routesForLocationService = client.routesForLocation() - val routesForLocationListResponse = + + val routesForLocations = routesForLocationService.list( RoutesForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) .query("query") - .radius(42.23) + .radius(0.0) .build() ) - println(routesForLocationListResponse) + + routesForLocations.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt index f684ec5..f9bc244 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt @@ -7,26 +7,28 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams @ExtendWith(TestServerExtension::class) -class ScheduleForRouteServiceTest { +internal class ScheduleForRouteServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val scheduleForRouteService = client.scheduleForRoute() - val scheduleForRouteRetrieveResponse = + + val scheduleForRoute = scheduleForRouteService.retrieve( ScheduleForRouteRetrieveParams.builder() - .routeId("routeID") + .routeId("1_100223") .date(LocalDate.parse("2019-12-27")) .build() ) - println(scheduleForRouteRetrieveResponse) + + scheduleForRoute.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt index 84fa8e0..caf1b82 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt @@ -7,26 +7,28 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams @ExtendWith(TestServerExtension::class) -class ScheduleForStopServiceTest { +internal class ScheduleForStopServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val scheduleForStopService = client.scheduleForStop() - val scheduleForStopRetrieveResponse = + + val scheduleForStop = scheduleForStopService.retrieve( ScheduleForStopRetrieveParams.builder() .stopId("stopID") .date(LocalDate.parse("2019-12-27")) .build() ) - println(scheduleForStopRetrieveResponse) + + scheduleForStop.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt index 2c1a5fa..712475d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt @@ -6,23 +6,25 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.searchforroute.SearchForRouteListParams @ExtendWith(TestServerExtension::class) -class SearchForRouteServiceTest { +internal class SearchForRouteServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val searchForRouteService = client.searchForRoute() - val searchForRouteListResponse = + + val searchForRoutes = searchForRouteService.list( - SearchForRouteListParams.builder().input("input").maxCount(123L).build() + SearchForRouteListParams.builder().input("input").maxCount(0L).build() ) - println(searchForRouteListResponse) + + searchForRoutes.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt index b9b1a95..1ce37be 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt @@ -6,23 +6,25 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.searchforstop.SearchForStopListParams @ExtendWith(TestServerExtension::class) -class SearchForStopServiceTest { +internal class SearchForStopServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val searchForStopService = client.searchForStop() - val searchForStopListResponse = + + val searchForStops = searchForStopService.list( - SearchForStopListParams.builder().input("input").maxCount(123L).build() + SearchForStopListParams.builder().input("input").maxCount(0L).build() ) - println(searchForStopListResponse) + + searchForStops.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt index 25431d2..c2a6daf 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt @@ -6,21 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class ShapeServiceTest { +internal class ShapeServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val shapeService = client.shape() - val shapeRetrieveResponse = - shapeService.retrieve(ShapeRetrieveParams.builder().shapeId("shapeID").build()) - println(shapeRetrieveResponse) + + val shape = shapeService.retrieve("shapeID") + + shape.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt index 143e7ce..a1aa457 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt @@ -6,23 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class StopIdsForAgencyServiceTest { +internal class StopIdsForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopIdsForAgencyService = client.stopIdsForAgency() - val stopIdsForAgencyListResponse = - stopIdsForAgencyService.list( - StopIdsForAgencyListParams.builder().agencyId("agencyID").build() - ) - println(stopIdsForAgencyListResponse) + + val stopIdsForAgencies = stopIdsForAgencyService.list("agencyID") + + stopIdsForAgencies.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt index 898436b..de4e314 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt @@ -6,21 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class StopServiceTest { +internal class StopServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopService = client.stop() - val stopRetrieveResponse = - stopService.retrieve(StopRetrieveParams.builder().stopId("stopID").build()) - println(stopRetrieveResponse) + + val stop = stopService.retrieve("stopID") + + stop.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt index 7cba930..8be4373 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt @@ -6,23 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class StopsForAgencyServiceTest { +internal class StopsForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopsForAgencyService = client.stopsForAgency() - val stopsForAgencyListResponse = - stopsForAgencyService.list( - StopsForAgencyListParams.builder().agencyId("agencyID").build() - ) - println(stopsForAgencyListResponse) + + val stopsForAgencies = stopsForAgencyService.list("agencyID") + + stopsForAgencies.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt index d3828a0..be4b08c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt @@ -6,30 +6,32 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams @ExtendWith(TestServerExtension::class) -class StopsForLocationServiceTest { +internal class StopsForLocationServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopsForLocationService = client.stopsForLocation() - val stopsForLocationListResponse = + + val stopsForLocations = stopsForLocationService.list( StopsForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) .query("query") - .radius(42.23) + .radius(0.0) .build() ) - println(stopsForLocationListResponse) + + stopsForLocations.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt index d5a42a4..4622d42 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt @@ -6,20 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.stopsforroute.StopsForRouteListParams @ExtendWith(TestServerExtension::class) -class StopsForRouteServiceTest { +internal class StopsForRouteServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopsForRouteService = client.stopsForRoute() - val stopsForRouteListResponse = + + val stopsForRoutes = stopsForRouteService.list( StopsForRouteListParams.builder() .routeId("routeID") @@ -27,6 +28,7 @@ class StopsForRouteServiceTest { .time("time") .build() ) - println(stopsForRouteListResponse) + + stopsForRoutes.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt index a5e8820..1f41a5c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt @@ -6,30 +6,32 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams @ExtendWith(TestServerExtension::class) -class TripDetailServiceTest { +internal class TripDetailServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripDetailService = client.tripDetails() - val tripDetailRetrieveResponse = + + val tripDetail = tripDetailService.retrieve( TripDetailRetrieveParams.builder() .tripId("tripID") .includeSchedule(true) .includeStatus(true) .includeTrip(true) - .serviceDate(123L) - .time(123L) + .serviceDate(0L) + .time(0L) .build() ) - println(tripDetailRetrieveResponse) + + tripDetail.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt index c3344e5..b44b32f 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt @@ -6,29 +6,31 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams @ExtendWith(TestServerExtension::class) -class TripForVehicleServiceTest { +internal class TripForVehicleServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripForVehicleService = client.tripForVehicle() - val tripForVehicleRetrieveResponse = + + val tripForVehicle = tripForVehicleService.retrieve( TripForVehicleRetrieveParams.builder() .vehicleId("vehicleID") .includeSchedule(true) .includeStatus(true) .includeTrip(true) - .time(123L) + .time(0L) .build() ) - println(tripForVehicleRetrieveResponse) + + tripForVehicle.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt index ce7d73b..597d6c9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt @@ -6,21 +6,21 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* @ExtendWith(TestServerExtension::class) -class TripServiceTest { +internal class TripServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripService = client.trip() - val tripRetrieveResponse = - tripService.retrieve(TripRetrieveParams.builder().tripId("tripID").build()) - println(tripRetrieveResponse) + + val trip = tripService.retrieve("tripID") + + trip.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt index 7c539e8..1042ce0 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt @@ -6,31 +6,33 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams @ExtendWith(TestServerExtension::class) -class TripsForLocationServiceTest { +internal class TripsForLocationServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripsForLocationService = client.tripsForLocation() - val tripsForLocationListResponse = + + val tripsForLocations = tripsForLocationService.list( TripsForLocationListParams.builder() - .lat(42.23) - .latSpan(42.23) - .lon(42.23) - .lonSpan(42.23) + .lat(0.0f) + .latSpan(0.0f) + .lon(0.0f) + .lonSpan(0.0f) .includeSchedule(true) .includeTrip(true) - .time(123L) + .time(0L) .build() ) - println(tripsForLocationListResponse) + + tripsForLocations.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt index 8568827..01f0580 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt @@ -6,28 +6,30 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.tripsforroute.TripsForRouteListParams @ExtendWith(TestServerExtension::class) -class TripsForRouteServiceTest { +internal class TripsForRouteServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripsForRouteService = client.tripsForRoute() - val tripsForRouteListResponse = + + val tripsForRoutes = tripsForRouteService.list( TripsForRouteListParams.builder() .routeId("routeID") .includeSchedule(true) .includeStatus(true) - .time(123L) + .time(0L) .build() ) - println(tripsForRouteListResponse) + + tripsForRoutes.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt index 701f148..1bb2a0b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt @@ -6,23 +6,25 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.onebusaway.TestServerExtension import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.models.* +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams @ExtendWith(TestServerExtension::class) -class VehiclesForAgencyServiceTest { +internal class VehiclesForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val vehiclesForAgencyService = client.vehiclesForAgency() - val vehiclesForAgencyListResponse = + + val vehiclesForAgencies = vehiclesForAgencyService.list( VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() ) - println(vehiclesForAgencyListResponse) + + vehiclesForAgencies.validate() } } diff --git a/onebusaway-sdk-java-example/build.gradle.kts b/onebusaway-sdk-java-example/build.gradle.kts index 2245a97..9e8670d 100644 --- a/onebusaway-sdk-java-example/build.gradle.kts +++ b/onebusaway-sdk-java-example/build.gradle.kts @@ -1,24 +1,21 @@ plugins { - id("java") + id("onebusaway-sdk.java") + application } -group = "org.onebusaway" -version = "0.1.0-alpha.4" - repositories { mavenCentral() } dependencies { - implementation(project(":onebusaway-sdk-java")) - implementation(project(mapOf("path" to ":onebusaway-sdk-java-core"))) - +} - testImplementation(platform("org.junit:junit-bom:5.9.1")) - testImplementation("org.junit.jupiter:junit-jupiter") +tasks.withType().configureEach { + // Allow using more modern APIs, like `List.of` and `Map.of`, in examples. + options.release.set(9) } -tasks.test { - useJUnitPlatform() -} \ No newline at end of file +application { + mainClass = "org.onebusaway.example.Main" +} diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java index c7986e5..0ac5c77 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams; +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse; public class AgenciesWithCoverage { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -19,10 +23,12 @@ public class AgenciesWithCoverage { public static void main(String[] args) { // Define the required Params - AgenciesWithCoverageListParams params = AgenciesWithCoverageListParams.builder().build(); + AgenciesWithCoverageListParams params = + AgenciesWithCoverageListParams.builder().build(); // Get the agencies with coverage - AgenciesWithCoverageListResponse agencies = client.agenciesWithCoverage().list(params); + AgenciesWithCoverageListResponse agencies = + client.agenciesWithCoverage().list(params); for (AgenciesWithCoverageListResponse.Data.List agency : agencies.data().list()) { System.out.println(agency); diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java index 24323c4..0b7d2c6 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.agency.AgencyRetrieveParams; +import org.onebusaway.models.agency.AgencyRetrieveResponse; public class Agency { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,18 +20,18 @@ public class Agency { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { - // Define the agency ID - String agencyId = "1"; + // Define the agency ID + String agencyId = "1"; - // Define the parameters for the agency retrieval request - AgencyRetrieveParams params = AgencyRetrieveParams.builder().agencyId(agencyId).build(); + // Define the parameters for the agency retrieval request + AgencyRetrieveParams params = + AgencyRetrieveParams.builder().agencyId(agencyId).build(); - // Retrieve the agency information - AgencyRetrieveResponse agency = client.agency().retrieve(params); + // Retrieve the agency information + AgencyRetrieveResponse agency = client.agency().retrieve(params); - System.out.println(agency); + System.out.println(agency); } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java index 1797047..2e3fed1 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams; +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveResponse; public class ArrivalAndDepartureForStop { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -32,8 +36,9 @@ public static void main(String[] args) { .serviceDate(serviceDate) // Use the Unix timestamp directly .build(); - // Retrieve arrival and departure information - ArrivalAndDepartureRetrieveResponse arrivalAndDepartureForStop = client.arrivalAndDeparture().retrieve(params); - System.out.println(arrivalAndDepartureForStop); + // Retrieve arrival and departure information + ArrivalAndDepartureRetrieveResponse arrivalAndDepartureForStop = + client.arrivalAndDeparture().retrieve(params); + System.out.println(arrivalAndDepartureForStop); } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java index 0646d70..03aaab8 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java @@ -2,12 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams; +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListResponse; + public class ArrivalsAndDeparturesForStop { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -15,7 +20,6 @@ public class ArrivalsAndDeparturesForStop { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the stop ID @@ -31,11 +35,12 @@ public static void main(String[] args) { .build(); // Retrieve arrival and departure information - ArrivalAndDepartureListResponse arrivalsAndDeparturesForStop = client.arrivalAndDeparture().list(params); + ArrivalAndDepartureListResponse arrivalsAndDeparturesForStop = + client.arrivalAndDeparture().list(params); - for (ArrivalAndDepartureListResponse.Data.Entry.ArrivalsAndDeparture arrivalAndDeparture : arrivalsAndDeparturesForStop.data().entry().arrivalsAndDepartures()) { + for (ArrivalAndDepartureListResponse.Data.Entry.ArrivalsAndDeparture arrivalAndDeparture : + arrivalsAndDeparturesForStop.data().entry().arrivalsAndDepartures()) { System.out.println(arrivalAndDeparture); } } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java index 504088d..457c310 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java @@ -3,12 +3,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.errors.OnebusawaySdkServiceException; -import org.onebusaway.models.*; +import org.onebusaway.models.block.BlockRetrieveParams; +import org.onebusaway.models.block.BlockRetrieveResponse; + public class Block { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,7 +21,6 @@ public class Block { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the block ID @@ -24,7 +28,8 @@ public static void main(String[] args) { try { // Define the parameters for the block retrieval request - BlockRetrieveParams params = BlockRetrieveParams.builder().blockId(blockId).build(); + BlockRetrieveParams params = + BlockRetrieveParams.builder().blockId(blockId).build(); // Retrieve the block information BlockRetrieveResponse block = client.block().retrieve(params); diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java index 4e8cbc0..432e2bf 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; public class CurrentTime { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,7 +20,6 @@ public class CurrentTime { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the parameters for the current time retrieval request @@ -27,6 +30,4 @@ public static void main(String[] args) { System.out.println(currentTime); } - - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java index a5a3232..b936b15 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java @@ -2,14 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; - +import org.onebusaway.models.route.RouteRetrieveParams; +import org.onebusaway.models.route.RouteRetrieveResponse; public class Route { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -17,23 +20,23 @@ public class Route { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { - // Define the route ID - String routeId = "1_100224"; + // Define the route ID + String routeId = "1_100224"; - try { + try { - RouteRetrieveParams params = org.onebusaway.models.RouteRetrieveParams.builder().routeId(routeId).build(); + RouteRetrieveParams params = + RouteRetrieveParams.builder().routeId(routeId).build(); - RouteRetrieveResponse route = client.route().retrieve(params); + RouteRetrieveResponse route = client.route().retrieve(params); - System.out.println(route); + System.out.println(route); - } catch (org.onebusaway.errors.OnebusawaySdkServiceException e) { - System.err.println("Error occurred: " + e.getMessage()); - System.err.println("Status Code: " + e.statusCode()); - } + } catch (org.onebusaway.errors.OnebusawaySdkServiceException e) { + System.err.println("Error occurred: " + e.getMessage()); + System.err.println("Status Code: " + e.statusCode()); + } } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java index 06e9f4a..4d81bee 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java @@ -3,13 +3,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.errors.OnebusawaySdkServiceException; -import org.onebusaway.models.*; +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams; +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse; public class RouteForAgency { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -17,7 +21,6 @@ public class RouteForAgency { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { try { @@ -26,24 +29,22 @@ public static void main(String[] args) { String agencyId = "1"; // Create the parameters for the routes for agency list request - RoutesForAgencyListParams params = RoutesForAgencyListParams.builder() - .agencyId(agencyId) - .build(); + RoutesForAgencyListParams params = + RoutesForAgencyListParams.builder().agencyId(agencyId).build(); // Retrieve the routes for the agency - RoutesForAgencyListResponse routesForAgency = client.routesForAgency().list(params); + RoutesForAgencyListResponse routesForAgency = + client.routesForAgency().list(params); - for (RoutesForAgencyListResponse.Data.List route : routesForAgency.data().list()) { + for (RoutesForAgencyListResponse.Data.List route : + routesForAgency.data().list()) { System.out.println(route); } - } - catch (OnebusawaySdkServiceException e) { + } catch (OnebusawaySdkServiceException e) { System.err.println("Error occurred: " + e.getMessage()); System.err.println("Status Code: " + e.statusCode()); - } - catch (Exception e) { + } catch (Exception e) { System.err.println("Error occurred: " + e.getMessage()); } } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java index e5fcf33..a211730 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams; +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse; public class RoutesForLocation { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,7 +20,6 @@ public class RoutesForLocation { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { try { @@ -33,15 +36,15 @@ public static void main(String[] args) { .build(); // Retrieve the routes for location - RoutesForLocationListResponse routesForLocation = client.routesForLocation().list(params); + RoutesForLocationListResponse routesForLocation = + client.routesForLocation().list(params); - for (RoutesForLocationListResponse.Data.List route : routesForLocation.data().list()) { + for (RoutesForLocationListResponse.Data.List route : + routesForLocation.data().list()) { System.out.println(route); } - } - catch (Exception e) { + } catch (Exception e) { System.err.println("Error occurred: " + e.getMessage()); } } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java index 6c755c1..1fe00d1 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams; +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse; public class ScheduleForRoute { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -24,12 +28,12 @@ public static void main(String[] args) { try { // Define the parameters for the schedule for route request - ScheduleForRouteRetrieveParams params = ScheduleForRouteRetrieveParams.builder() - .routeId(routeId) - .build(); + ScheduleForRouteRetrieveParams params = + ScheduleForRouteRetrieveParams.builder().routeId(routeId).build(); // Retrieve the schedule for the route - ScheduleForRouteRetrieveResponse scheduleForRoute = client.scheduleForRoute().retrieve(params); + ScheduleForRouteRetrieveResponse scheduleForRoute = + client.scheduleForRoute().retrieve(params); System.out.println(scheduleForRoute); @@ -43,6 +47,5 @@ public static void main(String[] args) { catch (Exception e) { System.err.println("Error occurred: " + e.getMessage()); } - } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java index 476086a..6fd0c09 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.searchforroute.SearchForRouteListParams; +import org.onebusaway.models.searchforroute.SearchForRouteListResponse; public class SearchForRoute { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,19 +20,19 @@ public class SearchForRoute { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { - // Define the search input - String searchInput = "crysta"; - - // Create the parameters for the route search request - SearchForRouteListParams params = SearchForRouteListParams.builder().input(searchInput).build(); + // Define the search input + String searchInput = "crysta"; - // Retrieve the route search results - SearchForRouteListResponse searchForRouteListResponse = client.searchForRoute().list(params); + // Create the parameters for the route search request + SearchForRouteListParams params = + SearchForRouteListParams.builder().input(searchInput).build(); - System.out.println(searchForRouteListResponse); + // Retrieve the route search results + SearchForRouteListResponse searchForRouteListResponse = + client.searchForRoute().list(params); + System.out.println(searchForRouteListResponse); } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java index 2894aa9..2d9ce45 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.searchforstop.SearchForStopListParams; +import org.onebusaway.models.searchforstop.SearchForStopListResponse; public class SearchForStop { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,19 +20,19 @@ public class SearchForStop { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the search input String searchInput = "crysta"; // Create the parameters for the stop search request - SearchForStopListParams params = SearchForStopListParams.builder().input(searchInput).build(); + SearchForStopListParams params = + SearchForStopListParams.builder().input(searchInput).build(); // Retrieve the stop search results - SearchForStopListResponse searchForStopListResponse = client.searchForStop().list(params); + SearchForStopListResponse searchForStopListResponse = + client.searchForStop().list(params); System.out.println(searchForStopListResponse); - } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java index 9c8e4aa..a5f15c1 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java @@ -2,33 +2,35 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.shape.ShapeRetrieveParams; +import org.onebusaway.models.shape.ShapeRetrieveResponse; public class Shape { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .apiKey(API_KEY) .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the shape ID String shapeId = "1_10002005"; // Define the parameters for the shape retrieval request - ShapeRetrieveParams params = ShapeRetrieveParams.builder().shapeId(shapeId).build(); + ShapeRetrieveParams params = + ShapeRetrieveParams.builder().shapeId(shapeId).build(); // Retrieve the shape information ShapeRetrieveResponse shape = client.shape().retrieve(params); System.out.println(shape.data()); } - - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java index 4f28923..984f293 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.stop.StopRetrieveParams; +import org.onebusaway.models.stop.StopRetrieveResponse; public class Stop { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,7 +20,6 @@ public class Stop { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the stop ID @@ -30,5 +33,4 @@ public static void main(String[] args) { System.out.println(stop); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java index 9238b18..893303d 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java @@ -1,18 +1,22 @@ package org.onebusaway.example; -import org.onebusaway.client.OnebusawaySdkClient; -import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; - import java.util.HashMap; import java.util.List; import java.util.Map; +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; +import org.onebusaway.models.*; +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams; +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse; public class StopsForLocation { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -56,14 +60,14 @@ public static void main(String[] args) { // For each stop, print associated routes for (String routeId : stop.routeIds()) { References.Route route = referenceMap.get(routeId); - if (route == null) continue; // Skip if route is not found + if (route == null) continue; // Skip if route is not found // Build a description for the route String routeDescription = buildRouteDescription(route); System.out.printf(" %s\n", routeDescription); } - System.out.println(); // Add a blank line between stops for clarity + System.out.println(); // Add a blank line between stops for clarity } } @@ -76,7 +80,7 @@ private static String buildRouteDescription(References.Route route) { // Append description if present route.description().ifPresent(desc -> { - if (!description.isEmpty()) { + if (description.length() > 0) { description.append(" - "); } description.append(desc); diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java index d103715..528fb41 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java @@ -2,12 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.stopsforroute.StopsForRouteListParams; +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse; + public class StopsForRoute { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -19,12 +24,12 @@ public static void main(String[] args) { // Define the route ID String routeId = "1_100229"; - StopsForRouteListParams params = StopsForRouteListParams.builder().routeId(routeId).build(); + StopsForRouteListParams params = + StopsForRouteListParams.builder().routeId(routeId).build(); // Get the stops for the route StopsForRouteListResponse stops = client.stopsForRoute().list(params); System.out.println(stops); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java index 134ab61..8142333 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams; +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse; public class StopsIdsForAgency { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -20,7 +24,8 @@ public static void main(String[] args) { // Define the agency ID String agencyId = "1"; - StopIdsForAgencyListParams params = StopIdsForAgencyListParams.builder().agencyId(agencyId).build(); + StopIdsForAgencyListParams params = + StopIdsForAgencyListParams.builder().agencyId(agencyId).build(); // Get the list of stop IDs for the agency StopIdsForAgencyListResponse stopIds = client.stopIdsForAgency().list(params); @@ -29,5 +34,4 @@ public static void main(String[] args) { System.out.println(stopId); } } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java index 90deb20..d23931f 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.trip.TripRetrieveParams; +import org.onebusaway.models.trip.TripRetrieveResponse; public class Trip { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -22,14 +26,11 @@ public static void main(String[] args) { String tripId = "40_608344966"; // Create the parameters for the trip retrieve request - TripRetrieveParams params = TripRetrieveParams.builder() - .tripId(tripId) - .build(); + TripRetrieveParams params = TripRetrieveParams.builder().tripId(tripId).build(); // Retrieve the trip TripRetrieveResponse trip = client.trip().retrieve(params); System.out.println(trip); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java index 3dfba06..cedeaef 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java @@ -2,12 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams; +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse; + public class TripDetails { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -17,19 +22,16 @@ public class TripDetails { public static void main(String[] args) { - // Define the trip ID - String tripId = "40_608344966"; - - // Create the parameters for the trip details request - TripDetailRetrieveParams params = TripDetailRetrieveParams .builder() - .tripId(tripId) - .build(); + // Define the trip ID + String tripId = "40_608344966"; + // Create the parameters for the trip details request + TripDetailRetrieveParams params = + TripDetailRetrieveParams.builder().tripId(tripId).build(); - // Retrieve the trip details - TripDetailRetrieveResponse tripDetails = client.tripDetails().retrieve(params); + // Retrieve the trip details + TripDetailRetrieveResponse tripDetails = client.tripDetails().retrieve(params); - System.out.println(tripDetails); + System.out.println(tripDetails); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java index ae4a33d..f39a8f8 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams; +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse; public class TripForVehicle { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -22,14 +26,12 @@ public static void main(String[] args) { String vehicleId = "1_3520"; // Retrieve the trip for the vehicle - TripForVehicleRetrieveParams params = TripForVehicleRetrieveParams.builder() - .vehicleId(vehicleId) - .build(); + TripForVehicleRetrieveParams params = + TripForVehicleRetrieveParams.builder().vehicleId(vehicleId).build(); // Retrieve the trip for the vehicle TripForVehicleRetrieveResponse tripForVehicle = client.tripForVehicle().retrieve(params); System.out.println(tripForVehicle); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java index 44c3ffb..51ec025 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.tripsforroute.TripsForRouteListParams; +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse; public class TripsForRoute { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -20,12 +24,12 @@ public static void main(String[] args) { // Define the route ID String routeId = "1_100224"; - TripsForRouteListParams params = TripsForRouteListParams.builder().routeId(routeId).build(); + TripsForRouteListParams params = + TripsForRouteListParams.builder().routeId(routeId).build(); // Get the trips for the route TripsForRouteListResponse trips = client.tripsForRoute().list(params); System.out.println(trips); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java index 6ed210f..0d25be4 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java @@ -2,13 +2,17 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams; +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse; public class VehiclesForAgency { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -20,12 +24,12 @@ public static void main(String[] args) { // Define the agency ID String agencyId = "1"; - VehiclesForAgencyListParams params = VehiclesForAgencyListParams.builder().agencyId(agencyId).build(); + VehiclesForAgencyListParams params = + VehiclesForAgencyListParams.builder().agencyId(agencyId).build(); // Get the vehicles for the agency VehiclesForAgencyListResponse vehicles = client.vehiclesForAgency().list(params); System.out.println(vehicles); } - } diff --git a/onebusaway-sdk-java/build.gradle.kts b/onebusaway-sdk-java/build.gradle.kts index 6d1a5d0..0e3ac39 100644 --- a/onebusaway-sdk-java/build.gradle.kts +++ b/onebusaway-sdk-java/build.gradle.kts @@ -6,3 +6,24 @@ plugins { dependencies { api(project(":onebusaway-sdk-java-client-okhttp")) } + +// Redefine `dokkaJavadoc` to: +// - Depend on the root project's task for merging the docs of all the projects +// - Forward that task's output to this task's output +tasks.named("dokkaJavadoc").configure { + actions.clear() + + val dokkaJavadocCollector = rootProject.tasks["dokkaJavadocCollector"] + dependsOn(dokkaJavadocCollector) + + val outputDirectory = project.layout.buildDirectory.dir("dokka/javadoc") + doLast { + copy { + from(dokkaJavadocCollector.outputs.files) + into(outputDirectory) + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } + } + + outputs.dir(outputDirectory) +} diff --git a/scripts/format b/scripts/format index c6239fa..456a69d 100755 --- a/scripts/format +++ b/scripts/format @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Running spotlessApply" -./gradlew --build-cache --parallel --no-daemon spotlessApply +./gradlew spotlessApply diff --git a/scripts/lint b/scripts/lint index 58753d0..e3a5f5e 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Build classes" -./gradlew --build-cache --parallel --no-daemon build testClasses -x test +./gradlew build testClasses -x test diff --git a/scripts/test b/scripts/test index 72ed033..6b750a7 100755 --- a/scripts/test +++ b/scripts/test @@ -53,4 +53,4 @@ else fi echo "==> Running tests" -./gradlew --build-cache --parallel --no-daemon test +./gradlew test