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

com.remondis.remap.Lang Maven / Gradle / Ivy

There is a newer version: 4.3.7
Show newest version
package com.remondis.remap;

/**
 * A utility class to provide some language features.
 *
 * @author schuettec
 */
class Lang {

  /**
   * This method throws an {@link IllegalArgumentException} if the specified argument is null.
   *
   * @param fieldName The parameter name.
   * @param argument The actual argument.
   * @return Returns the argument
   * @throws IllegalArgumentException Thrown with a detailed message if argument is null. Returns
   *         immediately otherwise.
   */
  static  T denyNull(String fieldName, T argument) throws IllegalArgumentException {
    if (argument == null) {
      if (fieldName == null) {
        throw new IllegalArgumentException("Argument may not be null.");
      } else {
        throw new IllegalArgumentException(String.format("Argument %s may not be null.", fieldName));
      }
    }
    return argument;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy