Skip to content

Commit 62453cd

Browse files
chore(internal): swap checkNotNull to checkRequired (#156)
1 parent 47ff5b1 commit 62453cd

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.openai.client.okhttp
22

33
import com.openai.core.RequestOptions
4+
import com.openai.core.checkRequired
45
import com.openai.core.http.Headers
56
import com.openai.core.http.HttpClient
67
import com.openai.core.http.HttpMethod
@@ -192,7 +193,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
192193
.callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30))
193194
.proxy(proxy)
194195
.build(),
195-
checkNotNull(baseUrl) { "`baseUrl` is required but was not set" },
196+
checkRequired("baseUrl", baseUrl),
196197
)
197198
}
198199
}

openai-java-core/src/main/kotlin/com/openai/core/Check.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
package com.openai.core
44

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

98
@JvmSynthetic

openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.openai.core.http
22

3+
import com.openai.core.checkRequired
34
import com.openai.core.toImmutable
45

56
class HttpRequest
@@ -134,7 +135,7 @@ private constructor(
134135

135136
fun build(): HttpRequest =
136137
HttpRequest(
137-
checkNotNull(method) { "`method` is required but was not set" },
138+
checkRequired("method", method),
138139
url,
139140
pathSegments.toImmutable(),
140141
headers.build(),

openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.openai.core.http
22

33
import com.openai.core.RequestOptions
4+
import com.openai.core.checkRequired
45
import com.openai.errors.OpenAIIoException
56
import java.io.IOException
67
import java.time.Clock
@@ -259,7 +260,7 @@ private constructor(
259260

260261
fun build(): HttpClient =
261262
RetryingHttpClient(
262-
checkNotNull(httpClient) { "`httpClient` is required but was not set" },
263+
checkRequired("httpClient", httpClient),
263264
clock,
264265
maxRetries,
265266
idempotencyHeader,

0 commit comments

Comments
 (0)