commonMain.com.apollographql.apollo.api.internal.Utils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo-api Show documentation
Show all versions of apollo-api Show documentation
Apollo GraphQL API classes
package com.apollographql.apollo.api.internal
import kotlin.jvm.JvmName
import kotlin.jvm.JvmStatic
/**
* Contains utility methods for checking Preconditions
*/
@Suppress("FunctionName")
object Utils {
/**
* Checks if the object is null. Returns the object if it is not null, else throws a NullPointerException with the
* error message.
*
* @param reference the object whose nullability has to be checked
* @param errorMessage the message to use with the NullPointerException
* @param the value type
* @return The object itself
* @throws NullPointerException if the object is null
*/
@JvmStatic
@JvmName("checkNotNull")
fun __checkNotNull(reference: T?, errorMessage: Any?): T {
if (reference == null) {
throw NullPointerException(errorMessage.toString())
}
return reference
}
/**
* Checks if the object is null. Returns the object if it is not null, else throws a NullPointerException.
*
* @param reference the object whose nullability has to be checked
* @param the value type
* @return The object itself
* @throws NullPointerException if the object is null
*/
@JvmStatic
@JvmName("checkNotNull")
fun __checkNotNull(reference: T?): T {
if (reference == null) {
throw NullPointerException()
}
return reference
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy