diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef24b0c..1d05e3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,17 @@ on: - 'integrated/**' - 'stl-preview-head/**' - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 @@ -35,6 +40,7 @@ jobs: timeout-minutes: 10 name: test runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 380b6f9..3188ced 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.24" + ".": "0.1.0-alpha.25" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ae94241..b1fe952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.25 (2025-07-07) + +Full Changelog: [v0.1.0-alpha.24...v0.1.0-alpha.25](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.24...v0.1.0-alpha.25) + +### Chores + +* **internal:** version bump ([97b8b21](https://github.com/OneBusAway/java-sdk/commit/97b8b21fb686dbf3ec55c42b57a69353a14ee6e8)) + ## 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) diff --git a/README.md b/README.md index a9ef60f..1aa8aef 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.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) +[![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.25) +[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.25/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.25) @@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.24). +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.25). @@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.onebusaway.org](https://de ### Gradle ```kotlin -implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.24") +implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.25") ``` ### Maven @@ -35,7 +35,7 @@ implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.24") org.onebusaway onebusaway-sdk-java - 0.1.0-alpha.24 + 0.1.0-alpha.25 ``` @@ -106,6 +106,21 @@ See this table for the available options: > Don't create more than one client in the same application. Each client has a connection pool and > thread pools, which are more efficient to share between requests. +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: + +```java +import org.onebusaway.client.OnebusawaySdkClient; + +OnebusawaySdkClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + ## Requests and responses To send a request to the Onebusaway SDK API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. diff --git a/SECURITY.md b/SECURITY.md index 8be07dc..8b844a0 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -16,11 +16,11 @@ before making any information public. ## Reporting Non-SDK Related Security Issues If you encounter security issues that are not directly related to SDKs but pertain to the services -or products provided by Onebusaway SDK please follow the respective company's security reporting guidelines. +or products provided by Onebusaway SDK, please follow the respective company's security reporting guidelines. ### Onebusaway SDK Terms and Policies -Please contact info@onebusaway.org for any questions or concerns regarding security of our services. +Please contact info@onebusaway.org for any questions or concerns regarding the security of our services. --- diff --git a/bin/check-release-environment b/bin/check-release-environment index 7dd019c..3a6a7b4 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,19 +3,19 @@ errors=() if [ -z "${SONATYPE_USERNAME}" ]; then - errors+=("The ONEBUSAWAY_SDK_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${SONATYPE_PASSWORD}" ]; then - errors+=("The ONEBUSAWAY_SDK_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${GPG_SIGNING_KEY}" ]; then - errors+=("The ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${GPG_SIGNING_PASSWORD}" ]; then - errors+=("The ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi lenErrors=${#errors[@]} diff --git a/build.gradle.kts b/build.gradle.kts index a036b20..852ee9e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "org.onebusaway" - version = "0.1.0-alpha.24" // x-release-please-version + version = "0.1.0-alpha.25" // x-release-please-version } subprojects { 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 32d8d5e..c748bbb 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 @@ -7,7 +7,6 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.Interceptor import okhttp3.MediaType @@ -20,7 +19,6 @@ 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 @@ -29,8 +27,7 @@ import org.onebusaway.core.http.HttpRequestBody import org.onebusaway.core.http.HttpResponse import org.onebusaway.errors.OnebusawaySdkIoException -class OkHttpClient -private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { @@ -142,11 +139,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun HttpRequest.toUrl(): String { - url?.let { - return it - } - - val builder = baseUrl.newBuilder() + val builder = baseUrl.toHttpUrl().newBuilder() pathSegments.forEach(builder::addPathSegment) queryParams.keys().forEach { key -> queryParams.values(key).forEach { builder.addQueryParameter(key, it) } @@ -196,12 +189,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { - private var baseUrl: HttpUrl? = null private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) @@ -216,8 +206,12 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .writeTimeout(timeout.write()) .callTimeout(timeout.request()) .proxy(proxy) - .build(), - checkRequired("baseUrl", baseUrl), + .build() + .apply { + // We usually make all our requests to the same host so it makes sense to + // raise the per-host limit to the overall limit. + dispatcher.maxRequestsPerHost = dispatcher.maxRequests + } ) } } diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt index 1c947e1..feeb9a0 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 @@ -163,13 +163,7 @@ class OnebusawaySdkOkHttpClient private constructor() { fun build(): OnebusawaySdkClient = OnebusawaySdkClientImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt index 40b84fd..7a64e64 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 @@ -164,13 +164,7 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { fun build(): OnebusawaySdkClientAsync = OnebusawaySdkClientAsyncImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } 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 6128438..5706000 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,6 +2,8 @@ package org.onebusaway.client +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.services.blocking.AgenciesWithCoverageService import org.onebusaway.services.blocking.AgencyService import org.onebusaway.services.blocking.ArrivalAndDepartureService @@ -60,6 +62,13 @@ interface OnebusawaySdkClient { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OnebusawaySdkClient + fun agenciesWithCoverage(): AgenciesWithCoverageService fun agency(): AgencyService @@ -134,6 +143,15 @@ interface OnebusawaySdkClient { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OnebusawaySdkClient.WithRawResponse + fun agenciesWithCoverage(): AgenciesWithCoverageService.WithRawResponse fun agency(): AgencyService.WithRawResponse 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 df8c27f..ddd6cf9 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,6 +2,8 @@ package org.onebusaway.client +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync import org.onebusaway.services.async.AgencyServiceAsync import org.onebusaway.services.async.ArrivalAndDepartureServiceAsync @@ -60,6 +62,13 @@ interface OnebusawaySdkClientAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OnebusawaySdkClientAsync + fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync fun agency(): AgencyServiceAsync @@ -135,6 +144,15 @@ interface OnebusawaySdkClientAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OnebusawaySdkClientAsync.WithRawResponse + fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse fun agency(): AgencyServiceAsync.WithRawResponse 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 b03336a..0b67cc5 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 @@ -2,6 +2,7 @@ package org.onebusaway.client +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.getPackageVersion import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync @@ -191,6 +192,9 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) : override fun withRawResponse(): OnebusawaySdkClientAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OnebusawaySdkClientAsync = + OnebusawaySdkClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync = agenciesWithCoverage override fun agency(): AgencyServiceAsync = agency @@ -366,6 +370,13 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) : ShapeServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): OnebusawaySdkClientAsync.WithRawResponse = + OnebusawaySdkClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse = agenciesWithCoverage 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 b3213c5..e3cde43 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 @@ -2,6 +2,7 @@ package org.onebusaway.client +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.getPackageVersion import org.onebusaway.services.blocking.AgenciesWithCoverageService @@ -182,6 +183,9 @@ class OnebusawaySdkClientImpl(private val clientOptions: ClientOptions) : Onebus override fun withRawResponse(): OnebusawaySdkClient.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OnebusawaySdkClient = + OnebusawaySdkClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun agenciesWithCoverage(): AgenciesWithCoverageService = agenciesWithCoverage override fun agency(): AgencyService = agency @@ -355,6 +359,13 @@ class OnebusawaySdkClientImpl(private val clientOptions: ClientOptions) : Onebus ShapeServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): OnebusawaySdkClient.WithRawResponse = + OnebusawaySdkClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun agenciesWithCoverage(): AgenciesWithCoverageService.WithRawResponse = agenciesWithCoverage 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 07ee264..c391485 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 @@ -4,6 +4,8 @@ package org.onebusaway.core import com.fasterxml.jackson.databind.json.JsonMapper import java.time.Clock +import java.util.Optional +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient import org.onebusaway.core.http.PhantomReachableClosingHttpClient @@ -17,7 +19,7 @@ private constructor( @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, - @get:JvmName("baseUrl") val baseUrl: String, + private val baseUrl: String?, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, @@ -32,6 +34,8 @@ private constructor( } } + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + fun toBuilder() = Builder().from(this) companion object { @@ -59,7 +63,7 @@ private constructor( private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() private var clock: Clock = Clock.systemUTC() - private var baseUrl: String = PRODUCTION_URL + private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false @@ -82,7 +86,9 @@ private constructor( apiKey = clientOptions.apiKey } - fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility @@ -92,7 +98,10 @@ private constructor( fun clock(clock: Clock) = apply { this.clock = clock } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -184,8 +193,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun baseUrl(): String = baseUrl - fun fromEnv() = apply { System.getenv("ONEBUSAWAY_SDK_BASE_URL")?.let { baseUrl(it) } System.getenv("ONEBUSAWAY_API_KEY")?.let { apiKey(it) } @@ -227,13 +234,11 @@ private constructor( return ClientOptions( httpClient, - PhantomReachableClosingHttpClient( - RetryingHttpClient.builder() - .httpClient(httpClient) - .clock(clock) - .maxRetries(maxRetries) - .build() - ), + RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build(), checkJacksonVersionCompatibility, jsonMapper, clock, 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 1b4396b..81a3ed9 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 @@ -6,7 +6,7 @@ import org.onebusaway.core.toImmutable class HttpRequest private constructor( @get:JvmName("method") val method: HttpMethod, - @get:JvmName("url") val url: String?, + @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("pathSegments") val pathSegments: List, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @@ -16,7 +16,7 @@ private constructor( fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = - "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" companion object { @JvmStatic fun builder() = Builder() @@ -25,7 +25,7 @@ private constructor( class Builder internal constructor() { private var method: HttpMethod? = null - private var url: String? = null + private var baseUrl: String? = null private var pathSegments: MutableList = mutableListOf() private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() @@ -34,7 +34,7 @@ private constructor( @JvmSynthetic internal fun from(request: HttpRequest) = apply { method = request.method - url = request.url + baseUrl = request.baseUrl pathSegments = request.pathSegments.toMutableList() headers = request.headers.toBuilder() queryParams = request.queryParams.toBuilder() @@ -43,7 +43,7 @@ private constructor( fun method(method: HttpMethod) = apply { this.method = method } - fun url(url: String) = apply { this.url = url } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } @@ -136,7 +136,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( checkRequired("method", method), - url, + checkRequired("baseUrl", baseUrl), pathSegments.toImmutable(), headers.build(), queryParams.build(), 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 3b4ca66..a811647 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams @@ -16,6 +17,13 @@ interface AgenciesWithCoverageServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgenciesWithCoverageServiceAsync + /** * Returns a list of all transit agencies currently supported by OneBusAway along with the * center of their coverage area. @@ -44,30 +52,35 @@ interface AgenciesWithCoverageServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/agencies-with-coverage.json`, but is * otherwise the same as [AgenciesWithCoverageServiceAsync.list]. */ - @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> = 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 ae8826a..44dbbc8 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 @@ -3,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -28,6 +29,13 @@ internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCov override fun withRawResponse(): AgenciesWithCoverageServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageServiceAsync = + AgenciesWithCoverageServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun list( params: AgenciesWithCoverageListParams, requestOptions: RequestOptions, @@ -40,6 +48,13 @@ internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCov private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageServiceAsync.WithRawResponse = + AgenciesWithCoverageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +66,7 @@ internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCov val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "agencies-with-coverage.json") .build() .prepareAsync(clientOptions, params) 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 65fa413..9dfd554 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.agency.AgencyRetrieveParams @@ -16,6 +17,13 @@ interface AgencyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgencyServiceAsync + /** Retrieve information for a specific transit agency identified by its unique ID. */ fun retrieve(agencyId: String): CompletableFuture = retrieve(agencyId, AgencyRetrieveParams.none()) @@ -56,16 +64,23 @@ interface AgencyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AgencyServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/agency/{agencyID}.json`, but is otherwise * the same as [AgencyServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(agencyId: String): CompletableFuture> = retrieve(agencyId, AgencyRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( agencyId: String, params: AgencyRetrieveParams = AgencyRetrieveParams.none(), @@ -74,7 +89,6 @@ interface AgencyServiceAsync { retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( agencyId: String, params: AgencyRetrieveParams = AgencyRetrieveParams.none(), @@ -82,21 +96,18 @@ interface AgencyServiceAsync { 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, 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 b4ee1be..c8d1328 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class AgencyServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): AgencyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AgencyServiceAsync = + AgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: AgencyRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class AgencyServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AgencyServiceAsync.WithRawResponse = + AgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class AgencyServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "agency", "${params._pathParam(0)}.json") .build() .prepareAsync(clientOptions, params) 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 5d85667..c7ec1ec 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams @@ -18,6 +19,13 @@ interface ArrivalAndDepartureServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ArrivalAndDepartureServiceAsync + /** arrival-and-departure-for-stop */ fun retrieve( stopId: String, @@ -88,12 +96,20 @@ interface ArrivalAndDepartureServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get * /api/where/arrival-and-departure-for-stop/{stopID}.json`, but is otherwise the same as * [ArrivalAndDepartureServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( stopId: String, params: ArrivalAndDepartureRetrieveParams, @@ -101,7 +117,6 @@ interface ArrivalAndDepartureServiceAsync { retrieve(stopId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( stopId: String, params: ArrivalAndDepartureRetrieveParams, @@ -110,14 +125,12 @@ interface ArrivalAndDepartureServiceAsync { 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(), @@ -128,14 +141,12 @@ interface ArrivalAndDepartureServiceAsync { * /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(), @@ -144,7 +155,6 @@ interface ArrivalAndDepartureServiceAsync { list(params.toBuilder().stopId(stopId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( stopId: String, params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), @@ -152,21 +162,18 @@ interface ArrivalAndDepartureServiceAsync { 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, 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 bc5c1ea..f7562bf 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -32,6 +33,13 @@ internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepar override fun withRawResponse(): ArrivalAndDepartureServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureServiceAsync = + ArrivalAndDepartureServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun retrieve( params: ArrivalAndDepartureRetrieveParams, requestOptions: RequestOptions, @@ -51,6 +59,13 @@ internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepar private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureServiceAsync.WithRawResponse = + ArrivalAndDepartureServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -65,6 +80,7 @@ internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepar val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", @@ -103,6 +119,7 @@ internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepar val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 543b005..157b478 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.block.BlockRetrieveParams @@ -16,6 +17,13 @@ interface BlockServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BlockServiceAsync + /** Get details of a specific block by ID */ fun retrieve(blockId: String): CompletableFuture = retrieve(blockId, BlockRetrieveParams.none()) @@ -54,16 +62,23 @@ interface BlockServiceAsync { /** A view of [BlockServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BlockServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/block/{blockID}.json`, but is otherwise * the same as [BlockServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(blockId: String): CompletableFuture> = retrieve(blockId, BlockRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( blockId: String, params: BlockRetrieveParams = BlockRetrieveParams.none(), @@ -72,7 +87,6 @@ interface BlockServiceAsync { retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( blockId: String, params: BlockRetrieveParams = BlockRetrieveParams.none(), @@ -80,21 +94,18 @@ interface BlockServiceAsync { 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, 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 30df072..eacb824 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class BlockServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): BlockServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BlockServiceAsync = + BlockServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: BlockRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class BlockServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BlockServiceAsync.WithRawResponse = + BlockServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class BlockServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "block", "${params._pathParam(0)}.json") .build() .prepareAsync(clientOptions, params) 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 13c3253..82559da 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.config.ConfigRetrieveParams @@ -16,6 +17,13 @@ interface ConfigServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigServiceAsync + /** config */ fun retrieve(): CompletableFuture = retrieve(ConfigRetrieveParams.none()) @@ -40,30 +48,35 @@ interface ConfigServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConfigServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/config.json`, but is otherwise the same * as [ConfigServiceAsync.retrieve]. */ - @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> = 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 c575a72..7806738 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 @@ -3,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -27,6 +28,9 @@ class ConfigServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): ConfigServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConfigServiceAsync = + ConfigServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ConfigRetrieveParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class ConfigServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ConfigServiceAsync.WithRawResponse = + ConfigServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class ConfigServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "config.json") .build() .prepareAsync(clientOptions, params) 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 6702fa8..4fe380f 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams @@ -16,6 +17,13 @@ interface CurrentTimeServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CurrentTimeServiceAsync + /** current-time */ fun retrieve(): CompletableFuture = retrieve(CurrentTimeRetrieveParams.none()) @@ -41,30 +49,35 @@ interface CurrentTimeServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CurrentTimeServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/current-time.json`, but is otherwise the * same as [CurrentTimeServiceAsync.retrieve]. */ - @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> = 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 c6e7e08..bdc80a2 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 @@ -3,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -27,6 +28,9 @@ class CurrentTimeServiceAsyncImpl internal constructor(private val clientOptions override fun withRawResponse(): CurrentTimeServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CurrentTimeServiceAsync = + CurrentTimeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: CurrentTimeRetrieveParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class CurrentTimeServiceAsyncImpl internal constructor(private val clientOptions private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CurrentTimeServiceAsync.WithRawResponse = + CurrentTimeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class CurrentTimeServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "current-time.json") .build() .prepareAsync(clientOptions, params) 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 9c5fadc..c3077cc 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper @@ -16,6 +17,13 @@ interface ReportProblemWithStopServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ReportProblemWithStopServiceAsync + /** Submit a user-generated problem report for a stop */ fun retrieve(stopId: String): CompletableFuture = retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) @@ -57,16 +65,23 @@ interface ReportProblemWithStopServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ReportProblemWithStopServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/report-problem-with-stop/{stopID}.json`, * but is otherwise the same as [ReportProblemWithStopServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(stopId: String): CompletableFuture> = retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( stopId: String, params: ReportProblemWithStopRetrieveParams = @@ -76,7 +91,6 @@ interface ReportProblemWithStopServiceAsync { retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( stopId: String, params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), @@ -84,21 +98,18 @@ interface ReportProblemWithStopServiceAsync { 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, 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 ff5765e..40c8069 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -30,6 +31,13 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi override fun withRawResponse(): ReportProblemWithStopServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ReportProblemWithStopServiceAsync = + ReportProblemWithStopServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun retrieve( params: ReportProblemWithStopRetrieveParams, requestOptions: RequestOptions, @@ -42,6 +50,13 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ReportProblemWithStopServiceAsync.WithRawResponse = + ReportProblemWithStopServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -55,6 +70,7 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 4ed86c7..cee5005 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper @@ -16,6 +17,13 @@ interface ReportProblemWithTripServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ReportProblemWithTripServiceAsync + /** Submit a user-generated problem report for a particular trip. */ fun retrieve(tripId: String): CompletableFuture = retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) @@ -57,16 +65,23 @@ interface ReportProblemWithTripServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ReportProblemWithTripServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/report-problem-with-trip/{tripID}.json`, * but is otherwise the same as [ReportProblemWithTripServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(tripId: String): CompletableFuture> = retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( tripId: String, params: ReportProblemWithTripRetrieveParams = @@ -76,7 +91,6 @@ interface ReportProblemWithTripServiceAsync { retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( tripId: String, params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), @@ -84,21 +98,18 @@ interface ReportProblemWithTripServiceAsync { 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, 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 c3f940e..aa61330 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -30,6 +31,13 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi override fun withRawResponse(): ReportProblemWithTripServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ReportProblemWithTripServiceAsync = + ReportProblemWithTripServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun retrieve( params: ReportProblemWithTripRetrieveParams, requestOptions: RequestOptions, @@ -42,6 +50,13 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ReportProblemWithTripServiceAsync.WithRawResponse = + ReportProblemWithTripServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -55,6 +70,7 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 af5ad86..c1550a2 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams @@ -16,6 +17,13 @@ interface RouteIdsForAgencyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteIdsForAgencyServiceAsync + /** Get route IDs for a specific agency */ fun list(agencyId: String): CompletableFuture = list(agencyId, RouteIdsForAgencyListParams.none()) @@ -59,18 +67,25 @@ interface RouteIdsForAgencyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/route-ids-for-agency/{agencyID}.json`, * but is otherwise the same as [RouteIdsForAgencyServiceAsync.list]. */ - @MustBeClosed fun list( agencyId: String ): CompletableFuture> = list(agencyId, RouteIdsForAgencyListParams.none()) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), @@ -79,7 +94,6 @@ interface RouteIdsForAgencyServiceAsync { list(params.toBuilder().agencyId(agencyId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), @@ -87,21 +101,18 @@ interface RouteIdsForAgencyServiceAsync { 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, 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 7040fa2..b79cf71 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,11 @@ internal constructor(private val clientOptions: ClientOptions) : RouteIdsForAgen override fun withRawResponse(): RouteIdsForAgencyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyServiceAsync = + RouteIdsForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: RouteIdsForAgencyListParams, requestOptions: RequestOptions, @@ -41,6 +47,13 @@ internal constructor(private val clientOptions: ClientOptions) : RouteIdsForAgen private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyServiceAsync.WithRawResponse = + RouteIdsForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : RouteIdsForAgen val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 96edd41..3b88408 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.route.RouteRetrieveParams @@ -16,6 +17,13 @@ interface RouteServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteServiceAsync + /** Retrieve information for a specific route identified by its unique ID. */ fun retrieve(routeId: String): CompletableFuture = retrieve(routeId, RouteRetrieveParams.none()) @@ -54,16 +62,23 @@ interface RouteServiceAsync { /** A view of [RouteServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RouteServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/route/{routeID}.json`, but is otherwise * the same as [RouteServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(routeId: String): CompletableFuture> = retrieve(routeId, RouteRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( routeId: String, params: RouteRetrieveParams = RouteRetrieveParams.none(), @@ -72,7 +87,6 @@ interface RouteServiceAsync { retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( routeId: String, params: RouteRetrieveParams = RouteRetrieveParams.none(), @@ -80,21 +94,18 @@ interface RouteServiceAsync { 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, 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 fa3f4c6..c390847 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): RouteServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RouteServiceAsync = + RouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: RouteRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RouteServiceAsync.WithRawResponse = + RouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "route", "${params._pathParam(0)}.json") .build() .prepareAsync(clientOptions, params) 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 579e603..fa95fee 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.routesforagency.RoutesForAgencyListParams @@ -16,6 +17,13 @@ interface RoutesForAgencyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RoutesForAgencyServiceAsync + /** Retrieve the list of all routes for a particular agency by id */ fun list(agencyId: String): CompletableFuture = list(agencyId, RoutesForAgencyListParams.none()) @@ -58,18 +66,25 @@ interface RoutesForAgencyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RoutesForAgencyServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/routes-for-agency/{agencyID}.json`, but * is otherwise the same as [RoutesForAgencyServiceAsync.list]. */ - @MustBeClosed fun list( agencyId: String ): CompletableFuture> = list(agencyId, RoutesForAgencyListParams.none()) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), @@ -78,7 +93,6 @@ interface RoutesForAgencyServiceAsync { list(params.toBuilder().agencyId(agencyId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), @@ -86,21 +100,18 @@ interface RoutesForAgencyServiceAsync { 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, 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 8401bec..b8648f9 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,11 @@ internal constructor(private val clientOptions: ClientOptions) : RoutesForAgency override fun withRawResponse(): RoutesForAgencyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): RoutesForAgencyServiceAsync = + RoutesForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: RoutesForAgencyListParams, requestOptions: RequestOptions, @@ -41,6 +47,13 @@ internal constructor(private val clientOptions: ClientOptions) : RoutesForAgency private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RoutesForAgencyServiceAsync.WithRawResponse = + RoutesForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : RoutesForAgency val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 3be0354..7d81a56 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.routesforlocation.RoutesForLocationListParams @@ -16,6 +17,13 @@ interface RoutesForLocationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RoutesForLocationServiceAsync + /** routes-for-location */ fun list( params: RoutesForLocationListParams @@ -33,18 +41,25 @@ interface RoutesForLocationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RoutesForLocationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/routes-for-location.json`, but is * otherwise the same as [RoutesForLocationServiceAsync.list]. */ - @MustBeClosed fun list( params: RoutesForLocationListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: RoutesForLocationListParams, requestOptions: RequestOptions = RequestOptions.none(), 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 4208b4d..97be387 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 @@ -3,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -27,6 +28,11 @@ internal constructor(private val clientOptions: ClientOptions) : RoutesForLocati override fun withRawResponse(): RoutesForLocationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): RoutesForLocationServiceAsync = + RoutesForLocationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: RoutesForLocationListParams, requestOptions: RequestOptions, @@ -39,6 +45,13 @@ internal constructor(private val clientOptions: ClientOptions) : RoutesForLocati private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RoutesForLocationServiceAsync.WithRawResponse = + RoutesForLocationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +63,7 @@ internal constructor(private val clientOptions: ClientOptions) : RoutesForLocati val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "routes-for-location.json") .build() .prepareAsync(clientOptions, params) 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 adf72f3..20c6989 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams @@ -16,6 +17,13 @@ interface ScheduleForRouteServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ScheduleForRouteServiceAsync + /** Retrieve the full schedule for a route on a particular day */ fun retrieve(routeId: String): CompletableFuture = retrieve(routeId, ScheduleForRouteRetrieveParams.none()) @@ -59,18 +67,25 @@ interface ScheduleForRouteServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ScheduleForRouteServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/schedule-for-route/{routeID}.json`, but * is otherwise the same as [ScheduleForRouteServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( routeId: String ): CompletableFuture> = retrieve(routeId, ScheduleForRouteRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( routeId: String, params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), @@ -79,7 +94,6 @@ interface ScheduleForRouteServiceAsync { retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( routeId: String, params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), @@ -87,21 +101,18 @@ interface ScheduleForRouteServiceAsync { 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, 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 e2d9e81..ca8ca7e 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,11 @@ internal constructor(private val clientOptions: ClientOptions) : ScheduleForRout override fun withRawResponse(): ScheduleForRouteServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ScheduleForRouteServiceAsync = + ScheduleForRouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ScheduleForRouteRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +47,13 @@ internal constructor(private val clientOptions: ClientOptions) : ScheduleForRout private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ScheduleForRouteServiceAsync.WithRawResponse = + ScheduleForRouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : ScheduleForRout val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 886f4a1..2907c69 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams @@ -16,6 +17,13 @@ interface ScheduleForStopServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ScheduleForStopServiceAsync + /** Get schedule for a specific stop */ fun retrieve(stopId: String): CompletableFuture = retrieve(stopId, ScheduleForStopRetrieveParams.none()) @@ -59,18 +67,25 @@ interface ScheduleForStopServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ScheduleForStopServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/schedule-for-stop/{stopID}.json`, but is * otherwise the same as [ScheduleForStopServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( stopId: String ): CompletableFuture> = retrieve(stopId, ScheduleForStopRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( stopId: String, params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), @@ -79,7 +94,6 @@ interface ScheduleForStopServiceAsync { retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( stopId: String, params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), @@ -87,21 +101,18 @@ interface ScheduleForStopServiceAsync { 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, 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 96f3b3d..05351f7 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,11 @@ internal constructor(private val clientOptions: ClientOptions) : ScheduleForStop override fun withRawResponse(): ScheduleForStopServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ScheduleForStopServiceAsync = + ScheduleForStopServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ScheduleForStopRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +47,13 @@ internal constructor(private val clientOptions: ClientOptions) : ScheduleForStop private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ScheduleForStopServiceAsync.WithRawResponse = + ScheduleForStopServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : ScheduleForStop val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 ea62172..671f10f 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.searchforroute.SearchForRouteListParams @@ -16,6 +17,13 @@ interface SearchForRouteServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SearchForRouteServiceAsync + /** Search for a route based on its name. */ fun list(params: SearchForRouteListParams): CompletableFuture = list(params, RequestOptions.none()) @@ -32,18 +40,25 @@ interface SearchForRouteServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SearchForRouteServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/search/route.json`, but is otherwise the * same as [SearchForRouteServiceAsync.list]. */ - @MustBeClosed fun list( params: SearchForRouteListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: SearchForRouteListParams, requestOptions: RequestOptions = RequestOptions.none(), 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 574b9ee..20dfb0f 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 @@ -3,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -27,6 +28,11 @@ internal constructor(private val clientOptions: ClientOptions) : SearchForRouteS override fun withRawResponse(): SearchForRouteServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): SearchForRouteServiceAsync = + SearchForRouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: SearchForRouteListParams, requestOptions: RequestOptions, @@ -39,6 +45,13 @@ internal constructor(private val clientOptions: ClientOptions) : SearchForRouteS private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SearchForRouteServiceAsync.WithRawResponse = + SearchForRouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +63,7 @@ internal constructor(private val clientOptions: ClientOptions) : SearchForRouteS val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "search", "route.json") .build() .prepareAsync(clientOptions, params) 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 525689c..c2f7d7f 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.searchforstop.SearchForStopListParams @@ -16,6 +17,13 @@ interface SearchForStopServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SearchForStopServiceAsync + /** Search for a stop based on its name. */ fun list(params: SearchForStopListParams): CompletableFuture = list(params, RequestOptions.none()) @@ -32,18 +40,25 @@ interface SearchForStopServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SearchForStopServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/search/stop.json`, but is otherwise the * same as [SearchForStopServiceAsync.list]. */ - @MustBeClosed fun list( params: SearchForStopListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: SearchForStopListParams, requestOptions: RequestOptions = RequestOptions.none(), 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 51078e2..ea2cde3 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 @@ -3,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -27,6 +28,9 @@ class SearchForStopServiceAsyncImpl internal constructor(private val clientOptio override fun withRawResponse(): SearchForStopServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SearchForStopServiceAsync = + SearchForStopServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: SearchForStopListParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class SearchForStopServiceAsyncImpl internal constructor(private val clientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SearchForStopServiceAsync.WithRawResponse = + SearchForStopServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class SearchForStopServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "search", "stop.json") .build() .prepareAsync(clientOptions, params) 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 4614a08..0cda608 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.shape.ShapeRetrieveParams @@ -16,6 +17,13 @@ interface ShapeServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ShapeServiceAsync + /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ fun retrieve(shapeId: String): CompletableFuture = retrieve(shapeId, ShapeRetrieveParams.none()) @@ -54,16 +62,23 @@ interface ShapeServiceAsync { /** A view of [ShapeServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ShapeServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/shape/{shapeID}.json`, but is otherwise * the same as [ShapeServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(shapeId: String): CompletableFuture> = retrieve(shapeId, ShapeRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( shapeId: String, params: ShapeRetrieveParams = ShapeRetrieveParams.none(), @@ -72,7 +87,6 @@ interface ShapeServiceAsync { retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( shapeId: String, params: ShapeRetrieveParams = ShapeRetrieveParams.none(), @@ -80,21 +94,18 @@ interface ShapeServiceAsync { 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, 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 17d585e..69df6ac 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class ShapeServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ShapeServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ShapeServiceAsync = + ShapeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ShapeRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class ShapeServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ShapeServiceAsync.WithRawResponse = + ShapeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class ShapeServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "shape", "${params._pathParam(0)}.json") .build() .prepareAsync(clientOptions, params) 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 6a2c5f9..34e9a4b 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams @@ -16,6 +17,13 @@ interface StopIdsForAgencyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopIdsForAgencyServiceAsync + /** Get stop IDs for a specific agency */ fun list(agencyId: String): CompletableFuture = list(agencyId, StopIdsForAgencyListParams.none()) @@ -58,18 +66,25 @@ interface StopIdsForAgencyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopIdsForAgencyServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stop-ids-for-agency/{agencyID}.json`, but * is otherwise the same as [StopIdsForAgencyServiceAsync.list]. */ - @MustBeClosed fun list( agencyId: String ): CompletableFuture> = list(agencyId, StopIdsForAgencyListParams.none()) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), @@ -78,7 +93,6 @@ interface StopIdsForAgencyServiceAsync { list(params.toBuilder().agencyId(agencyId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), @@ -86,21 +100,18 @@ interface StopIdsForAgencyServiceAsync { 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, 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 bbe0917..78999aa 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,11 @@ internal constructor(private val clientOptions: ClientOptions) : StopIdsForAgenc override fun withRawResponse(): StopIdsForAgencyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): StopIdsForAgencyServiceAsync = + StopIdsForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: StopIdsForAgencyListParams, requestOptions: RequestOptions, @@ -41,6 +47,13 @@ internal constructor(private val clientOptions: ClientOptions) : StopIdsForAgenc private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopIdsForAgencyServiceAsync.WithRawResponse = + StopIdsForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : StopIdsForAgenc val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 597b17d..25761a3 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stop.StopRetrieveParams @@ -16,6 +17,13 @@ interface StopServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopServiceAsync + /** Get details of a specific stop */ fun retrieve(stopId: String): CompletableFuture = retrieve(stopId, StopRetrieveParams.none()) @@ -54,16 +62,21 @@ interface StopServiceAsync { /** A view of [StopServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stop/{stopID}.json`, but is otherwise the * same as [StopServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(stopId: String): CompletableFuture> = retrieve(stopId, StopRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( stopId: String, params: StopRetrieveParams = StopRetrieveParams.none(), @@ -72,7 +85,6 @@ interface StopServiceAsync { retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( stopId: String, params: StopRetrieveParams = StopRetrieveParams.none(), @@ -80,21 +92,18 @@ interface StopServiceAsync { 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, 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 81d7c5a..ae752dd 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class StopServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): StopServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): StopServiceAsync = + StopServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: StopRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class StopServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopServiceAsync.WithRawResponse = + StopServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class StopServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "stop", "${params._pathParam(0)}.json") .build() .prepareAsync(clientOptions, params) 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 af0198f..e68be44 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stopsforagency.StopsForAgencyListParams @@ -16,6 +17,13 @@ interface StopsForAgencyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForAgencyServiceAsync + /** Get stops for a specific agency */ fun list(agencyId: String): CompletableFuture = list(agencyId, StopsForAgencyListParams.none()) @@ -57,16 +65,23 @@ interface StopsForAgencyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForAgencyServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stops-for-agency/{agencyID}.json`, but is * otherwise the same as [StopsForAgencyServiceAsync.list]. */ - @MustBeClosed fun list(agencyId: String): CompletableFuture> = list(agencyId, StopsForAgencyListParams.none()) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: StopsForAgencyListParams = StopsForAgencyListParams.none(), @@ -75,7 +90,6 @@ interface StopsForAgencyServiceAsync { list(params.toBuilder().agencyId(agencyId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: StopsForAgencyListParams = StopsForAgencyListParams.none(), @@ -83,21 +97,18 @@ interface StopsForAgencyServiceAsync { 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, 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 08a34be..e9a4151 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,11 @@ internal constructor(private val clientOptions: ClientOptions) : StopsForAgencyS override fun withRawResponse(): StopsForAgencyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): StopsForAgencyServiceAsync = + StopsForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: StopsForAgencyListParams, requestOptions: RequestOptions, @@ -41,6 +47,13 @@ internal constructor(private val clientOptions: ClientOptions) : StopsForAgencyS private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopsForAgencyServiceAsync.WithRawResponse = + StopsForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : StopsForAgencyS val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 764ff9a..def885d 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stopsforlocation.StopsForLocationListParams @@ -16,6 +17,13 @@ interface StopsForLocationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForLocationServiceAsync + /** stops-for-location */ fun list(params: StopsForLocationListParams): CompletableFuture = list(params, RequestOptions.none()) @@ -32,18 +40,25 @@ interface StopsForLocationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForLocationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stops-for-location.json`, but is * otherwise the same as [StopsForLocationServiceAsync.list]. */ - @MustBeClosed fun list( params: StopsForLocationListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: StopsForLocationListParams, requestOptions: RequestOptions = RequestOptions.none(), 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 586b618..31aefd9 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 @@ -3,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -27,6 +28,11 @@ internal constructor(private val clientOptions: ClientOptions) : StopsForLocatio override fun withRawResponse(): StopsForLocationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): StopsForLocationServiceAsync = + StopsForLocationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: StopsForLocationListParams, requestOptions: RequestOptions, @@ -39,6 +45,13 @@ internal constructor(private val clientOptions: ClientOptions) : StopsForLocatio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopsForLocationServiceAsync.WithRawResponse = + StopsForLocationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +63,7 @@ internal constructor(private val clientOptions: ClientOptions) : StopsForLocatio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "stops-for-location.json") .build() .prepareAsync(clientOptions, params) 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 59f7969..6695f1a 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stopsforroute.StopsForRouteListParams @@ -16,6 +17,13 @@ interface StopsForRouteServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForRouteServiceAsync + /** Get stops for a specific route */ fun list(routeId: String): CompletableFuture = list(routeId, StopsForRouteListParams.none()) @@ -57,16 +65,23 @@ interface StopsForRouteServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForRouteServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stops-for-route/{routeID}.json`, but is * otherwise the same as [StopsForRouteServiceAsync.list]. */ - @MustBeClosed fun list(routeId: String): CompletableFuture> = list(routeId, StopsForRouteListParams.none()) /** @see [list] */ - @MustBeClosed fun list( routeId: String, params: StopsForRouteListParams = StopsForRouteListParams.none(), @@ -75,7 +90,6 @@ interface StopsForRouteServiceAsync { list(params.toBuilder().routeId(routeId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( routeId: String, params: StopsForRouteListParams = StopsForRouteListParams.none(), @@ -83,21 +97,18 @@ interface StopsForRouteServiceAsync { 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, 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 4739e7d..b8f821f 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class StopsForRouteServiceAsyncImpl internal constructor(private val clientOptio override fun withRawResponse(): StopsForRouteServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): StopsForRouteServiceAsync = + StopsForRouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: StopsForRouteListParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class StopsForRouteServiceAsyncImpl internal constructor(private val clientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopsForRouteServiceAsync.WithRawResponse = + StopsForRouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class StopsForRouteServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 5de78ae..1a7804a 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.tripdetails.TripDetailRetrieveParams @@ -16,6 +17,13 @@ interface TripDetailServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripDetailServiceAsync + /** Retrieve Trip Details */ fun retrieve(tripId: String): CompletableFuture = retrieve(tripId, TripDetailRetrieveParams.none()) @@ -58,18 +66,25 @@ interface TripDetailServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripDetailServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trip-details/{tripID}.json`, but is * otherwise the same as [TripDetailServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( tripId: String ): CompletableFuture> = retrieve(tripId, TripDetailRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( tripId: String, params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), @@ -78,7 +93,6 @@ interface TripDetailServiceAsync { retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( tripId: String, params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), @@ -86,21 +100,18 @@ interface TripDetailServiceAsync { 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, 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 95045d3..b8d3d76 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class TripDetailServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): TripDetailServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TripDetailServiceAsync = + TripDetailServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: TripDetailRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class TripDetailServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripDetailServiceAsync.WithRawResponse = + TripDetailServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class TripDetailServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "trip-details", "${params._pathParam(0)}.json") .build() .prepareAsync(clientOptions, params) 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 3446b32..91e9220 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams @@ -16,6 +17,13 @@ interface TripForVehicleServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripForVehicleServiceAsync + /** Retrieve trip for a specific vehicle */ fun retrieve(vehicleId: String): CompletableFuture = retrieve(vehicleId, TripForVehicleRetrieveParams.none()) @@ -59,18 +67,25 @@ interface TripForVehicleServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripForVehicleServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trip-for-vehicle/{vehicleID}.json`, but * is otherwise the same as [TripForVehicleServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( vehicleId: String ): CompletableFuture> = retrieve(vehicleId, TripForVehicleRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( vehicleId: String, params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), @@ -79,7 +94,6 @@ interface TripForVehicleServiceAsync { retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( vehicleId: String, params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), @@ -87,21 +101,18 @@ interface TripForVehicleServiceAsync { 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, 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 4307268..ff42d3d 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,11 @@ internal constructor(private val clientOptions: ClientOptions) : TripForVehicleS override fun withRawResponse(): TripForVehicleServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): TripForVehicleServiceAsync = + TripForVehicleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: TripForVehicleRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +47,13 @@ internal constructor(private val clientOptions: ClientOptions) : TripForVehicleS private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripForVehicleServiceAsync.WithRawResponse = + TripForVehicleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : TripForVehicleS val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 e137c1a..fea1192 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.trip.TripRetrieveParams @@ -16,6 +17,13 @@ interface TripServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripServiceAsync + /** Get details of a specific trip */ fun retrieve(tripId: String): CompletableFuture = retrieve(tripId, TripRetrieveParams.none()) @@ -54,16 +62,21 @@ interface TripServiceAsync { /** A view of [TripServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trip/{tripID}.json`, but is otherwise the * same as [TripServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(tripId: String): CompletableFuture> = retrieve(tripId, TripRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( tripId: String, params: TripRetrieveParams = TripRetrieveParams.none(), @@ -72,7 +85,6 @@ interface TripServiceAsync { retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( tripId: String, params: TripRetrieveParams = TripRetrieveParams.none(), @@ -80,21 +92,18 @@ interface TripServiceAsync { 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, 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 428e431..16578d2 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class TripServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): TripServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TripServiceAsync = + TripServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: TripRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class TripServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripServiceAsync.WithRawResponse = + TripServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class TripServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "trip", "${params._pathParam(0)}.json") .build() .prepareAsync(clientOptions, params) 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 0290143..b65d24b 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.tripsforlocation.TripsForLocationListParams @@ -16,6 +17,13 @@ interface TripsForLocationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripsForLocationServiceAsync + /** Retrieve trips for a given location */ fun list(params: TripsForLocationListParams): CompletableFuture = list(params, RequestOptions.none()) @@ -32,18 +40,25 @@ interface TripsForLocationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripsForLocationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trips-for-location.json`, but is * otherwise the same as [TripsForLocationServiceAsync.list]. */ - @MustBeClosed fun list( params: TripsForLocationListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: TripsForLocationListParams, requestOptions: RequestOptions = RequestOptions.none(), 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 472f2c2..9db32e7 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 @@ -3,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -27,6 +28,11 @@ internal constructor(private val clientOptions: ClientOptions) : TripsForLocatio override fun withRawResponse(): TripsForLocationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): TripsForLocationServiceAsync = + TripsForLocationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: TripsForLocationListParams, requestOptions: RequestOptions, @@ -39,6 +45,13 @@ internal constructor(private val clientOptions: ClientOptions) : TripsForLocatio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripsForLocationServiceAsync.WithRawResponse = + TripsForLocationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +63,7 @@ internal constructor(private val clientOptions: ClientOptions) : TripsForLocatio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "trips-for-location.json") .build() .prepareAsync(clientOptions, params) 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 b9b2161..23ce174 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.tripsforroute.TripsForRouteListParams @@ -16,6 +17,13 @@ interface TripsForRouteServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripsForRouteServiceAsync + /** Search for active trips for a specific route. */ fun list(routeId: String): CompletableFuture = list(routeId, TripsForRouteListParams.none()) @@ -57,16 +65,23 @@ interface TripsForRouteServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripsForRouteServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trips-for-route/{routeID}.json`, but is * otherwise the same as [TripsForRouteServiceAsync.list]. */ - @MustBeClosed fun list(routeId: String): CompletableFuture> = list(routeId, TripsForRouteListParams.none()) /** @see [list] */ - @MustBeClosed fun list( routeId: String, params: TripsForRouteListParams = TripsForRouteListParams.none(), @@ -75,7 +90,6 @@ interface TripsForRouteServiceAsync { list(params.toBuilder().routeId(routeId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( routeId: String, params: TripsForRouteListParams = TripsForRouteListParams.none(), @@ -83,21 +97,18 @@ interface TripsForRouteServiceAsync { 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, 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 11c93c2..f21a0d8 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,9 @@ class TripsForRouteServiceAsyncImpl internal constructor(private val clientOptio override fun withRawResponse(): TripsForRouteServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TripsForRouteServiceAsync = + TripsForRouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: TripsForRouteListParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class TripsForRouteServiceAsyncImpl internal constructor(private val clientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripsForRouteServiceAsync.WithRawResponse = + TripsForRouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class TripsForRouteServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 78aed5c..90e2aec 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 @@ -2,8 +2,9 @@ package org.onebusaway.services.async -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams @@ -16,6 +17,13 @@ interface VehiclesForAgencyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VehiclesForAgencyServiceAsync + /** Get vehicles for a specific agency */ fun list(agencyId: String): CompletableFuture = list(agencyId, VehiclesForAgencyListParams.none()) @@ -59,18 +67,25 @@ interface VehiclesForAgencyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VehiclesForAgencyServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/vehicles-for-agency/{agencyID}.json`, but * is otherwise the same as [VehiclesForAgencyServiceAsync.list]. */ - @MustBeClosed fun list( agencyId: String ): CompletableFuture> = list(agencyId, VehiclesForAgencyListParams.none()) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), @@ -79,7 +94,6 @@ interface VehiclesForAgencyServiceAsync { list(params.toBuilder().agencyId(agencyId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( agencyId: String, params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), @@ -87,21 +101,18 @@ interface VehiclesForAgencyServiceAsync { 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, 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 aa2e990..b7c185b 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,6 +3,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -29,6 +30,11 @@ internal constructor(private val clientOptions: ClientOptions) : VehiclesForAgen override fun withRawResponse(): VehiclesForAgencyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): VehiclesForAgencyServiceAsync = + VehiclesForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: VehiclesForAgencyListParams, requestOptions: RequestOptions, @@ -41,6 +47,13 @@ internal constructor(private val clientOptions: ClientOptions) : VehiclesForAgen private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): VehiclesForAgencyServiceAsync.WithRawResponse = + VehiclesForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : VehiclesForAgen val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 1f18b1c..5571efa 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams @@ -15,6 +17,13 @@ interface AgenciesWithCoverageService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgenciesWithCoverageService + /** * Returns a list of all transit agencies currently supported by OneBusAway along with the * center of their coverage area. @@ -42,6 +51,15 @@ interface AgenciesWithCoverageService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/agencies-with-coverage.json`, but is * otherwise the same as [AgenciesWithCoverageService.list]. 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 a109b92..a4fe9e6 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 @@ -2,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -26,6 +27,11 @@ internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCov override fun withRawResponse(): AgenciesWithCoverageService.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageService = + AgenciesWithCoverageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: AgenciesWithCoverageListParams, requestOptions: RequestOptions, @@ -38,6 +44,13 @@ internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCov private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageService.WithRawResponse = + AgenciesWithCoverageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +62,7 @@ internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCov val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "agencies-with-coverage.json") .build() .prepare(clientOptions, params) 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 2d98f44..6006a50 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.agency.AgencyRetrieveParams @@ -15,6 +17,13 @@ interface AgencyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgencyService + /** Retrieve information for a specific transit agency identified by its unique ID. */ fun retrieve(agencyId: String): AgencyRetrieveResponse = retrieve(agencyId, AgencyRetrieveParams.none()) @@ -50,6 +59,13 @@ interface AgencyService { /** A view of [AgencyService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgencyService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/agency/{agencyID}.json`, but is otherwise * the same as [AgencyService.retrieve]. 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 e8e2b39..1290266 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class AgencyServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): AgencyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AgencyService = + AgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: AgencyRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class AgencyServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AgencyService.WithRawResponse = + AgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class AgencyServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "agency", "${params._pathParam(0)}.json") .build() .prepare(clientOptions, params) 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 0638304..3832b1a 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams @@ -17,6 +19,13 @@ interface ArrivalAndDepartureService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ArrivalAndDepartureService + /** arrival-and-departure-for-stop */ fun retrieve( stopId: String, @@ -79,6 +88,15 @@ interface ArrivalAndDepartureService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureService.WithRawResponse + /** * Returns a raw HTTP response for `get * /api/where/arrival-and-departure-for-stop/{stopID}.json`, but is otherwise the same as 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 cee01ad..e5e72db 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -30,6 +31,11 @@ internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepar override fun withRawResponse(): ArrivalAndDepartureService.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureService = + ArrivalAndDepartureServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ArrivalAndDepartureRetrieveParams, requestOptions: RequestOptions, @@ -49,6 +55,13 @@ internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepar private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureService.WithRawResponse = + ArrivalAndDepartureServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -63,6 +76,7 @@ internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepar val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", @@ -98,6 +112,7 @@ internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepar val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 0508966..2d5b874 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.block.BlockRetrieveParams @@ -15,6 +17,13 @@ interface BlockService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BlockService + /** Get details of a specific block by ID */ fun retrieve(blockId: String): BlockRetrieveResponse = retrieve(blockId, BlockRetrieveParams.none()) @@ -49,6 +58,13 @@ interface BlockService { /** A view of [BlockService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BlockService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/block/{blockID}.json`, but is otherwise * the same as [BlockService.retrieve]. 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 04ec198..6158126 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class BlockServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): BlockService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BlockService = + BlockServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: BlockRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class BlockServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BlockService.WithRawResponse = + BlockServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class BlockServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "block", "${params._pathParam(0)}.json") .build() .prepare(clientOptions, params) 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 fdce05f..0f29491 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.config.ConfigRetrieveParams @@ -15,6 +17,13 @@ interface ConfigService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigService + /** config */ fun retrieve(): ConfigRetrieveResponse = retrieve(ConfigRetrieveParams.none()) @@ -36,6 +45,13 @@ interface ConfigService { /** A view of [ConfigService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/config.json`, but is otherwise the same * as [ConfigService.retrieve]. 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 e4e752b..35d9426 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 @@ -2,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -26,6 +27,9 @@ class ConfigServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): ConfigService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConfigService = + ConfigServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ConfigRetrieveParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class ConfigServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ConfigService.WithRawResponse = + ConfigServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class ConfigServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "config.json") .build() .prepare(clientOptions, params) 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 2d912a3..623e455 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams @@ -15,6 +17,13 @@ interface CurrentTimeService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CurrentTimeService + /** current-time */ fun retrieve(): CurrentTimeRetrieveResponse = retrieve(CurrentTimeRetrieveParams.none()) @@ -38,6 +47,15 @@ interface CurrentTimeService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CurrentTimeService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/current-time.json`, but is otherwise the * same as [CurrentTimeService.retrieve]. 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 ee69013..e354ae5 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 @@ -2,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -26,6 +27,9 @@ class CurrentTimeServiceImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): CurrentTimeService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CurrentTimeService = + CurrentTimeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: CurrentTimeRetrieveParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class CurrentTimeServiceImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CurrentTimeService.WithRawResponse = + CurrentTimeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class CurrentTimeServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "current-time.json") .build() .prepare(clientOptions, params) 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 2869322..7c61a2c 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper @@ -15,6 +17,13 @@ interface ReportProblemWithStopService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ReportProblemWithStopService + /** Submit a user-generated problem report for a stop */ fun retrieve(stopId: String): ResponseWrapper = retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) @@ -52,6 +61,15 @@ interface ReportProblemWithStopService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ReportProblemWithStopService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/report-problem-with-stop/{stopID}.json`, * but is otherwise the same as [ReportProblemWithStopService.retrieve]. 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 91a98bc..7872acd 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,11 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi override fun withRawResponse(): ReportProblemWithStopService.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ReportProblemWithStopService = + ReportProblemWithStopServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ReportProblemWithStopRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +46,13 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ReportProblemWithStopService.WithRawResponse = + ReportProblemWithStopServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -53,6 +66,7 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 db963a6..bc4688d 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper @@ -15,6 +17,13 @@ interface ReportProblemWithTripService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ReportProblemWithTripService + /** Submit a user-generated problem report for a particular trip. */ fun retrieve(tripId: String): ResponseWrapper = retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) @@ -52,6 +61,15 @@ interface ReportProblemWithTripService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ReportProblemWithTripService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/report-problem-with-trip/{tripID}.json`, * but is otherwise the same as [ReportProblemWithTripService.retrieve]. 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 48e57de..2ace7ca 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,11 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi override fun withRawResponse(): ReportProblemWithTripService.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ReportProblemWithTripService = + ReportProblemWithTripServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ReportProblemWithTripRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +46,13 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ReportProblemWithTripService.WithRawResponse = + ReportProblemWithTripServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -53,6 +66,7 @@ internal constructor(private val clientOptions: ClientOptions) : ReportProblemWi val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 5709b20..2cd23ee 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams @@ -15,6 +17,13 @@ interface RouteIdsForAgencyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteIdsForAgencyService + /** Get route IDs for a specific agency */ fun list(agencyId: String): RouteIdsForAgencyListResponse = list(agencyId, RouteIdsForAgencyListParams.none()) @@ -53,6 +62,15 @@ interface RouteIdsForAgencyService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/route-ids-for-agency/{agencyID}.json`, * but is otherwise the same as [RouteIdsForAgencyService.list]. 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 44ef629..339a903 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class RouteIdsForAgencyServiceImpl internal constructor(private val clientOption override fun withRawResponse(): RouteIdsForAgencyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RouteIdsForAgencyService = + RouteIdsForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: RouteIdsForAgencyListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class RouteIdsForAgencyServiceImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyService.WithRawResponse = + RouteIdsForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class RouteIdsForAgencyServiceImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 1f304b0..23977bc 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.route.RouteRetrieveParams @@ -15,6 +17,13 @@ interface RouteService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteService + /** Retrieve information for a specific route identified by its unique ID. */ fun retrieve(routeId: String): RouteRetrieveResponse = retrieve(routeId, RouteRetrieveParams.none()) @@ -49,6 +58,13 @@ interface RouteService { /** A view of [RouteService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/route/{routeID}.json`, but is otherwise * the same as [RouteService.retrieve]. 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 bca72fb..c6106c9 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): RouteService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RouteService = + RouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: RouteRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RouteService.WithRawResponse = + RouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "route", "${params._pathParam(0)}.json") .build() .prepare(clientOptions, params) 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 9b00bdd..e24c54f 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.routesforagency.RoutesForAgencyListParams @@ -15,6 +17,13 @@ interface RoutesForAgencyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RoutesForAgencyService + /** Retrieve the list of all routes for a particular agency by id */ fun list(agencyId: String): RoutesForAgencyListResponse = list(agencyId, RoutesForAgencyListParams.none()) @@ -53,6 +62,15 @@ interface RoutesForAgencyService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RoutesForAgencyService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/routes-for-agency/{agencyID}.json`, but * is otherwise the same as [RoutesForAgencyService.list]. 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 101ed80..0383c97 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class RoutesForAgencyServiceImpl internal constructor(private val clientOptions: override fun withRawResponse(): RoutesForAgencyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RoutesForAgencyService = + RoutesForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: RoutesForAgencyListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class RoutesForAgencyServiceImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RoutesForAgencyService.WithRawResponse = + RoutesForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class RoutesForAgencyServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 0096c2b..305a226 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.routesforlocation.RoutesForLocationListParams @@ -15,6 +17,13 @@ interface RoutesForLocationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RoutesForLocationService + /** routes-for-location */ fun list(params: RoutesForLocationListParams): RoutesForLocationListResponse = list(params, RequestOptions.none()) @@ -31,6 +40,15 @@ interface RoutesForLocationService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RoutesForLocationService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/routes-for-location.json`, but is * otherwise the same as [RoutesForLocationService.list]. 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 442e156..a543465 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 @@ -2,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -26,6 +27,9 @@ class RoutesForLocationServiceImpl internal constructor(private val clientOption override fun withRawResponse(): RoutesForLocationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RoutesForLocationService = + RoutesForLocationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: RoutesForLocationListParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class RoutesForLocationServiceImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RoutesForLocationService.WithRawResponse = + RoutesForLocationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class RoutesForLocationServiceImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "routes-for-location.json") .build() .prepare(clientOptions, params) 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 2979d2f..58799dc 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams @@ -15,6 +17,13 @@ interface ScheduleForRouteService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ScheduleForRouteService + /** Retrieve the full schedule for a route on a particular day */ fun retrieve(routeId: String): ScheduleForRouteRetrieveResponse = retrieve(routeId, ScheduleForRouteRetrieveParams.none()) @@ -56,6 +65,15 @@ interface ScheduleForRouteService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ScheduleForRouteService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/schedule-for-route/{routeID}.json`, but * is otherwise the same as [ScheduleForRouteService.retrieve]. 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 51fcebf..9c1025b 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class ScheduleForRouteServiceImpl internal constructor(private val clientOptions override fun withRawResponse(): ScheduleForRouteService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ScheduleForRouteService = + ScheduleForRouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ScheduleForRouteRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ScheduleForRouteServiceImpl internal constructor(private val clientOptions private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ScheduleForRouteService.WithRawResponse = + ScheduleForRouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class ScheduleForRouteServiceImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 605661b..ac35b8f 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams @@ -15,6 +17,13 @@ interface ScheduleForStopService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ScheduleForStopService + /** Get schedule for a specific stop */ fun retrieve(stopId: String): ScheduleForStopRetrieveResponse = retrieve(stopId, ScheduleForStopRetrieveParams.none()) @@ -53,6 +62,15 @@ interface ScheduleForStopService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ScheduleForStopService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/schedule-for-stop/{stopID}.json`, but is * otherwise the same as [ScheduleForStopService.retrieve]. 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 fbf848d..b32656a 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class ScheduleForStopServiceImpl internal constructor(private val clientOptions: override fun withRawResponse(): ScheduleForStopService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ScheduleForStopService = + ScheduleForStopServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ScheduleForStopRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ScheduleForStopServiceImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ScheduleForStopService.WithRawResponse = + ScheduleForStopServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class ScheduleForStopServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 04b354e..a4111f4 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.searchforroute.SearchForRouteListParams @@ -15,6 +17,13 @@ interface SearchForRouteService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SearchForRouteService + /** Search for a route based on its name. */ fun list(params: SearchForRouteListParams): SearchForRouteListResponse = list(params, RequestOptions.none()) @@ -30,6 +39,15 @@ interface SearchForRouteService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SearchForRouteService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/search/route.json`, but is otherwise the * same as [SearchForRouteService.list]. 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 ff5e599..12338ea 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 @@ -2,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -26,6 +27,9 @@ class SearchForRouteServiceImpl internal constructor(private val clientOptions: override fun withRawResponse(): SearchForRouteService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SearchForRouteService = + SearchForRouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: SearchForRouteListParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class SearchForRouteServiceImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SearchForRouteService.WithRawResponse = + SearchForRouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class SearchForRouteServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "search", "route.json") .build() .prepare(clientOptions, params) 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 f11dbd7..e2c2f95 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.searchforstop.SearchForStopListParams @@ -15,6 +17,13 @@ interface SearchForStopService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SearchForStopService + /** Search for a stop based on its name. */ fun list(params: SearchForStopListParams): SearchForStopListResponse = list(params, RequestOptions.none()) @@ -30,6 +39,15 @@ interface SearchForStopService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SearchForStopService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/search/stop.json`, but is otherwise the * same as [SearchForStopService.list]. 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 2c9e4b0..56898f8 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 @@ -2,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -26,6 +27,9 @@ class SearchForStopServiceImpl internal constructor(private val clientOptions: C override fun withRawResponse(): SearchForStopService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SearchForStopService = + SearchForStopServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: SearchForStopListParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class SearchForStopServiceImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SearchForStopService.WithRawResponse = + SearchForStopServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class SearchForStopServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "search", "stop.json") .build() .prepare(clientOptions, params) 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 d82d700..ff02cff 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.shape.ShapeRetrieveParams @@ -15,6 +17,13 @@ interface ShapeService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ShapeService + /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ fun retrieve(shapeId: String): ShapeRetrieveResponse = retrieve(shapeId, ShapeRetrieveParams.none()) @@ -49,6 +58,13 @@ interface ShapeService { /** A view of [ShapeService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ShapeService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/shape/{shapeID}.json`, but is otherwise * the same as [ShapeService.retrieve]. 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 1d1d961..cfae3d7 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class ShapeServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): ShapeService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ShapeService = + ShapeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ShapeRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ShapeServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ShapeService.WithRawResponse = + ShapeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class ShapeServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "shape", "${params._pathParam(0)}.json") .build() .prepare(clientOptions, params) 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 aadb2ac..08c77c7 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams @@ -15,6 +17,13 @@ interface StopIdsForAgencyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopIdsForAgencyService + /** Get stop IDs for a specific agency */ fun list(agencyId: String): StopIdsForAgencyListResponse = list(agencyId, StopIdsForAgencyListParams.none()) @@ -53,6 +62,15 @@ interface StopIdsForAgencyService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopIdsForAgencyService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stop-ids-for-agency/{agencyID}.json`, but * is otherwise the same as [StopIdsForAgencyService.list]. 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 13d621b..cc9694f 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class StopIdsForAgencyServiceImpl internal constructor(private val clientOptions override fun withRawResponse(): StopIdsForAgencyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): StopIdsForAgencyService = + StopIdsForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: StopIdsForAgencyListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class StopIdsForAgencyServiceImpl internal constructor(private val clientOptions private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopIdsForAgencyService.WithRawResponse = + StopIdsForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class StopIdsForAgencyServiceImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 ff15b60..3bc172a 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stop.StopRetrieveParams @@ -15,6 +17,13 @@ interface StopService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopService + /** Get details of a specific stop */ fun retrieve(stopId: String): StopRetrieveResponse = retrieve(stopId, StopRetrieveParams.none()) @@ -48,6 +57,13 @@ interface StopService { /** A view of [StopService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stop/{stopID}.json`, but is otherwise the * same as [StopService.retrieve]. 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 78b0a9a..16bc9f6 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -27,6 +28,9 @@ class StopServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): StopService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): StopService = + StopServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: StopRetrieveParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class StopServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopService.WithRawResponse = + StopServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -53,6 +64,7 @@ class StopServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "stop", "${params._pathParam(0)}.json") .build() .prepare(clientOptions, params) 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 6bd2fde..5786d9b 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stopsforagency.StopsForAgencyListParams @@ -15,6 +17,13 @@ interface StopsForAgencyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForAgencyService + /** Get stops for a specific agency */ fun list(agencyId: String): StopsForAgencyListResponse = list(agencyId, StopsForAgencyListParams.none()) @@ -52,6 +61,15 @@ interface StopsForAgencyService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForAgencyService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stops-for-agency/{agencyID}.json`, but is * otherwise the same as [StopsForAgencyService.list]. 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 ce8ac3b..a6b0eae 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class StopsForAgencyServiceImpl internal constructor(private val clientOptions: override fun withRawResponse(): StopsForAgencyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): StopsForAgencyService = + StopsForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: StopsForAgencyListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class StopsForAgencyServiceImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopsForAgencyService.WithRawResponse = + StopsForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class StopsForAgencyServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 fc4606c..77b795d 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stopsforlocation.StopsForLocationListParams @@ -15,6 +17,13 @@ interface StopsForLocationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForLocationService + /** stops-for-location */ fun list(params: StopsForLocationListParams): StopsForLocationListResponse = list(params, RequestOptions.none()) @@ -31,6 +40,15 @@ interface StopsForLocationService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForLocationService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stops-for-location.json`, but is * otherwise the same as [StopsForLocationService.list]. 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 37a9da8..bce57c8 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 @@ -2,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -26,6 +27,9 @@ class StopsForLocationServiceImpl internal constructor(private val clientOptions override fun withRawResponse(): StopsForLocationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): StopsForLocationService = + StopsForLocationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: StopsForLocationListParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class StopsForLocationServiceImpl internal constructor(private val clientOptions private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopsForLocationService.WithRawResponse = + StopsForLocationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class StopsForLocationServiceImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "stops-for-location.json") .build() .prepare(clientOptions, params) 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 5c91312..99fa8df 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.stopsforroute.StopsForRouteListParams @@ -15,6 +17,13 @@ interface StopsForRouteService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForRouteService + /** Get stops for a specific route */ fun list(routeId: String): StopsForRouteListResponse = list(routeId, StopsForRouteListParams.none()) @@ -51,6 +60,15 @@ interface StopsForRouteService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForRouteService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/stops-for-route/{routeID}.json`, but is * otherwise the same as [StopsForRouteService.list]. 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 59690be..2789fe6 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class StopsForRouteServiceImpl internal constructor(private val clientOptions: C override fun withRawResponse(): StopsForRouteService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): StopsForRouteService = + StopsForRouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: StopsForRouteListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class StopsForRouteServiceImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): StopsForRouteService.WithRawResponse = + StopsForRouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class StopsForRouteServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 942f586..e1a5494 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.tripdetails.TripDetailRetrieveParams @@ -15,6 +17,13 @@ interface TripDetailService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripDetailService + /** Retrieve Trip Details */ fun retrieve(tripId: String): TripDetailRetrieveResponse = retrieve(tripId, TripDetailRetrieveParams.none()) @@ -50,6 +59,15 @@ interface TripDetailService { /** A view of [TripDetailService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripDetailService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trip-details/{tripID}.json`, but is * otherwise the same as [TripDetailService.retrieve]. 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 4c96e8d..5e22aee 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class TripDetailServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): TripDetailService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TripDetailService = + TripDetailServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: TripDetailRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class TripDetailServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripDetailService.WithRawResponse = + TripDetailServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class TripDetailServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "trip-details", "${params._pathParam(0)}.json") .build() .prepare(clientOptions, params) 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 e0c77c2..abed6ff 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams @@ -15,6 +17,13 @@ interface TripForVehicleService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripForVehicleService + /** Retrieve trip for a specific vehicle */ fun retrieve(vehicleId: String): TripForVehicleRetrieveResponse = retrieve(vehicleId, TripForVehicleRetrieveParams.none()) @@ -55,6 +64,15 @@ interface TripForVehicleService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripForVehicleService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trip-for-vehicle/{vehicleID}.json`, but * is otherwise the same as [TripForVehicleService.retrieve]. 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 bbb0d41..53448f2 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class TripForVehicleServiceImpl internal constructor(private val clientOptions: override fun withRawResponse(): TripForVehicleService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TripForVehicleService = + TripForVehicleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: TripForVehicleRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class TripForVehicleServiceImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripForVehicleService.WithRawResponse = + TripForVehicleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class TripForVehicleServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 170dec6..a824874 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.trip.TripRetrieveParams @@ -15,6 +17,13 @@ interface TripService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripService + /** Get details of a specific trip */ fun retrieve(tripId: String): TripRetrieveResponse = retrieve(tripId, TripRetrieveParams.none()) @@ -48,6 +57,13 @@ interface TripService { /** A view of [TripService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trip/{tripID}.json`, but is otherwise the * same as [TripService.retrieve]. 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 6cd67ed..a24dc13 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -27,6 +28,9 @@ class TripServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): TripService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TripService = + TripServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: TripRetrieveParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class TripServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripService.WithRawResponse = + TripServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -53,6 +64,7 @@ class TripServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "trip", "${params._pathParam(0)}.json") .build() .prepare(clientOptions, params) 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 f313dba..0a4ad13 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.tripsforlocation.TripsForLocationListParams @@ -15,6 +17,13 @@ interface TripsForLocationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripsForLocationService + /** Retrieve trips for a given location */ fun list(params: TripsForLocationListParams): TripsForLocationListResponse = list(params, RequestOptions.none()) @@ -31,6 +40,15 @@ interface TripsForLocationService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripsForLocationService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trips-for-location.json`, but is * otherwise the same as [TripsForLocationService.list]. 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 6a5576b..40b81b7 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 @@ -2,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions @@ -26,6 +27,9 @@ class TripsForLocationServiceImpl internal constructor(private val clientOptions override fun withRawResponse(): TripsForLocationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TripsForLocationService = + TripsForLocationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: TripsForLocationListParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class TripsForLocationServiceImpl internal constructor(private val clientOptions private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripsForLocationService.WithRawResponse = + TripsForLocationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class TripsForLocationServiceImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("api", "where", "trips-for-location.json") .build() .prepare(clientOptions, params) 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 449719e..4cf5aff 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.tripsforroute.TripsForRouteListParams @@ -15,6 +17,13 @@ interface TripsForRouteService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripsForRouteService + /** Search for active trips for a specific route. */ fun list(routeId: String): TripsForRouteListResponse = list(routeId, TripsForRouteListParams.none()) @@ -51,6 +60,15 @@ interface TripsForRouteService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripsForRouteService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/trips-for-route/{routeID}.json`, but is * otherwise the same as [TripsForRouteService.list]. 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 f63ee3a..908a404 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class TripsForRouteServiceImpl internal constructor(private val clientOptions: C override fun withRawResponse(): TripsForRouteService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TripsForRouteService = + TripsForRouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: TripsForRouteListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class TripsForRouteServiceImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TripsForRouteService.WithRawResponse = + TripsForRouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class TripsForRouteServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", 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 836379a..1b5fd21 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 @@ -3,6 +3,8 @@ package org.onebusaway.services.blocking import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions import org.onebusaway.core.RequestOptions import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams @@ -15,6 +17,13 @@ interface VehiclesForAgencyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VehiclesForAgencyService + /** Get vehicles for a specific agency */ fun list(agencyId: String): VehiclesForAgencyListResponse = list(agencyId, VehiclesForAgencyListParams.none()) @@ -53,6 +62,15 @@ interface VehiclesForAgencyService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VehiclesForAgencyService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/where/vehicles-for-agency/{agencyID}.json`, but * is otherwise the same as [VehiclesForAgencyService.list]. 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 2a854ae..a911f03 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,6 +2,7 @@ package org.onebusaway.services.blocking +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions import org.onebusaway.core.JsonValue @@ -28,6 +29,9 @@ class VehiclesForAgencyServiceImpl internal constructor(private val clientOption override fun withRawResponse(): VehiclesForAgencyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): VehiclesForAgencyService = + VehiclesForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: VehiclesForAgencyListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class VehiclesForAgencyServiceImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): VehiclesForAgencyService.WithRawResponse = + VehiclesForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class VehiclesForAgencyServiceImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", "where", diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt new file mode 100644 index 0000000..356afe7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify +import org.onebusaway.core.http.HttpClient + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + private val httpClient = mock() + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + var clientOptions = + ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt index 49ef7ce..2d0736f 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 @@ -20,11 +20,13 @@ import org.onebusaway.core.RequestOptions internal class RetryingHttpClientTest { private var openResponseCount = 0 + private lateinit var baseUrl: String private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() httpClient = object : HttpClient { @@ -75,7 +77,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -97,7 +103,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -139,7 +149,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -187,6 +201,7 @@ internal class RetryingHttpClientTest { retryingClient.execute( HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(baseUrl) .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), @@ -223,7 +238,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, )