Skip to content

Commit

Permalink
chore(internal): swap checkNotNull to checkRequired (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jan 24, 2025
1 parent 48fc646 commit d6f65f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.openai.client.okhttp

import com.openai.core.RequestOptions
import com.openai.core.checkRequired
import com.openai.core.http.Headers
import com.openai.core.http.HttpClient
import com.openai.core.http.HttpMethod
Expand Down Expand Up @@ -192,7 +193,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
.callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30))
.proxy(proxy)
.build(),
checkNotNull(baseUrl) { "`baseUrl` is required but was not set" },
checkRequired("baseUrl", baseUrl),
)
}
}
3 changes: 1 addition & 2 deletions openai-java-core/src/main/kotlin/com/openai/core/Check.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

package com.openai.core

@JvmSynthetic
internal fun <T : Any> checkRequired(name: String, value: T?): T =
fun <T : Any> checkRequired(name: String, value: T?): T =
checkNotNull(value) { "`$name` is required, but was not set" }

@JvmSynthetic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.openai.core.http

import com.openai.core.checkRequired
import com.openai.core.toImmutable

class HttpRequest
Expand Down Expand Up @@ -134,7 +135,7 @@ private constructor(

fun build(): HttpRequest =
HttpRequest(
checkNotNull(method) { "`method` is required but was not set" },
checkRequired("method", method),
url,
pathSegments.toImmutable(),
headers.build(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.openai.core.http

import com.openai.core.RequestOptions
import com.openai.core.checkRequired
import com.openai.errors.OpenAIIoException
import java.io.IOException
import java.time.Clock
Expand Down Expand Up @@ -259,7 +260,7 @@ private constructor(

fun build(): HttpClient =
RetryingHttpClient(
checkNotNull(httpClient) { "`httpClient` is required but was not set" },
checkRequired("httpClient", httpClient),
clock,
maxRetries,
idempotencyHeader,
Expand Down

0 comments on commit d6f65f7

Please sign in to comment.