com.increase.api.core.RequestOptions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of increase-java-core Show documentation
Show all versions of increase-java-core Show documentation
An SDK library for increase
The newest version!
package com.increase.api.core
import java.time.Duration
class RequestOptions
private constructor(
val responseValidation: Boolean?,
val timeout: Duration?,
) {
fun applyDefaults(options: RequestOptions): RequestOptions {
return RequestOptions(
responseValidation = this.responseValidation ?: options.responseValidation,
timeout = this.timeout ?: options.timeout,
)
}
companion object {
private val NONE = builder().build()
@JvmStatic fun none() = NONE
@JvmStatic fun builder() = Builder()
}
class Builder {
private var responseValidation: Boolean? = null
private var timeout: Duration? = null
fun responseValidation(responseValidation: Boolean) = apply {
this.responseValidation = responseValidation
}
fun timeout(timeout: Duration) = apply { this.timeout = timeout }
fun build(): RequestOptions {
return RequestOptions(responseValidation, timeout)
}
}
}