All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.apollographql.apollo.api.internal.Utils.kt Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy