Skip to content

Commit a2f92fb

Browse files
style(internal): make getOrThrow terse and consistent (#363)
1 parent 8f9e6fa commit a2f92fb

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

  • lithic-java-core/src/main/kotlin/com/lithic/api/core

lithic-java-core/src/main/kotlin/com/lithic/api/core/Utils.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@ import com.lithic.api.errors.LithicInvalidDataException
99
import java.util.Collections
1010

1111
@JvmSynthetic
12-
internal fun <T : Any> T?.getOrThrow(name: String): T {
13-
if (this == null) {
14-
throw LithicInvalidDataException("'${name}' is not present")
15-
}
16-
17-
return this
18-
}
12+
internal fun <T : Any> T?.getOrThrow(name: String): T =
13+
this ?: throw LithicInvalidDataException("`${name}` is not present")
1914

2015
@JvmSynthetic
2116
internal fun <T> List<T>.toUnmodifiable(): List<T> {

0 commit comments

Comments
 (0)