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

com.codepoetics.fluvius.preconditions.Preconditions Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package com.codepoetics.fluvius.preconditions;

/**
 * Utility class for checking arguments, especially to enforce non-nullity.
 */
public final class Preconditions {

  private Preconditions() {
  }

  /**
   * Throws an informative exception if the supplied value is null
   *
   * @param name  The name of the variable being tested.
   * @param value The value of the variable being tested.
   * @param    The type of the variable being tested.
   * @return The (guaranteed non-null) value of the variable being tested.
   */
  public static  T checkNotNull(String name, T value) {
    if (name == null) {
      throw new NullPointerException("name must not be null");
    }
    if (value == null) {
      throw new NullPointerException(name + " must not be null");
    }
    return value;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy