<commit_before>/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.util;

import java.util.Map;

import org.slf4j.helpers.MessageFormatter;

/**
 * Contains utility methods for checking inputs to methods.
 */
public final class ArgumentChecker {

  /**
   * Restricted constructor.
   */
  private ArgumentChecker() {
  }

  //-------------------------------------------------------------------------
  /**
   * Checks that the specified boolean is true.
   * This will normally be the result of a caller-specific check.
   * 
   * @param trueIfValid  a boolean resulting from testing an argument, may be null
   * @param message  the error message, not null
   * @throws IllegalArgumentException if the test value is false
   */
  public static void isTrue(boolean trueIfValid, String message) {
    if (trueIfValid == false) {
      throw new IllegalArgumentException(message);
    }
  }
  
  /**
   * Checks that the specified boolean is true.
   * This will normally be the result of a caller-specific check.
   * 
   * @param trueIfValid  a boolean resulting from testing an argument, may be null
   * @param message  the error message, not null
   * @param arg  the message arguments
   * @throws IllegalArgumentException if the test value is false
   */
  public static void isTrue(boolean trueIfValid, String message, Object... arg) {
    if (trueIfValid == false) {
      throw new IllegalArgumentException(MessageFormatter.arrayFormat(message, arg));
    }
  }  

  /**
   * Checks that the specified boolean is false.
   * This will normally be the result of a caller-specific check.
   * 
   * @param falseIfValid  a boolean resulting from testing an argument, may be null
   * @param message  the error message, not null
   * @throws IllegalArgumentException if the test value is false
   */
  public static void isFalse(boolean falseIfValid, String message) {
    if (falseIfValid) {
      throw new IllegalArgumentException(message);
    }
  }

  /**
   * Checks that the specified boolean is false.
   * This will normally be the result of a caller-specific check.
   * 
   * @param falseIfValid  a boolean resulting from testing an argument, may be null
   * @param message  the error message, not null
   * @param arg  the message arguments
   * @throws IllegalArgumentException if the test value is false
   */
  public static void isFalse(boolean falseIfValid, String message, Object... arg) {
    if (falseIfValid) {
      throw new IllegalArgumentException(MessageFormatter.arrayFormat(message, arg));
    }
  }
  
  //-------------------------------------------------------------------------
  /**
   * Checks that the specified parameter is non-null.
   * 
   * @param parameter  the parameter to check, may be null
   * @param name  the name of the parameter to use in the error message, not null
   * @throws IllegalArgumentException if the input is null
   */
  public static void notNull(Object parameter, String name) {
    if (parameter == null) {
      throw new IllegalArgumentException("Input parameter '" + name + "' must not be null");
    }
  }

  /**
   * Checks that the specified injected parameter is non-null.
   * As a convention, the name of the parameter should be the exact name that you would
   * provide in a Spring configuration file.
   * 
   * @param parameter  the parameter to check, may be null
   * @param name  the name of the parameter to use in the error message, not null
   * @throws IllegalArgumentException if the input is null
   */
  public static void notNullInjected(Object parameter, String name) {
    if (parameter == null) {
      throw new IllegalArgumentException("Injected input parameter '" + name + "' must not be null");<commit_msg>Fixed code that wouldn't compile.<commit_after>/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.util;

import java.util.Map;

import org.slf4j.helpers.MessageFormatter;

/**
 * Contains utility methods for checking inputs to methods.
 */
public final class ArgumentChecker {

  /**
   * Restricted constructor.
   */
  private ArgumentChecker() {
  }

  //-------------------------------------------------------------------------
  /**
   * Checks that the specified boolean is true.
   * This will normally be the result of a caller-specific check.
   * 
   * @param trueIfValid  a boolean resulting from testing an argument, may be null
   * @param message  the error message, not null
   * @throws IllegalArgumentException if the test value is false
   */
  public static void isTrue(boolean trueIfValid, String message) {
    if (trueIfValid == false) {
      throw new IllegalArgumentException(message);
    }
  }
  
  /**
   * Checks that the specified boolean is true.
   * This will normally be the result of a caller-specific check.
   * 
   * @param trueIfValid  a boolean resulting from testing an argument, may be null
   * @param message  the error message, not null
   * @param arg  the message arguments
   * @throws IllegalArgumentException if the test value is false
   */
  public static void isTrue(boolean trueIfValid, String message, Object... arg) {
    if (trueIfValid == false) {
      throw new IllegalArgumentException(MessageFormatter.arrayFormat(message, arg).getMessage());
    }
  }  

  /**
   * Checks that the specified boolean is false.
   * This will normally be the result of a caller-specific check.
   * 
   * @param falseIfValid  a boolean resulting from testing an argument, may be null
   * @param message  the error message, not null
   * @throws IllegalArgumentException if the test value is false
   */
  public static void isFalse(boolean falseIfValid, String message) {
    if (falseIfValid) {
      throw new IllegalArgumentException(message);
    }
  }

  /**
   * Checks that the specified boolean is false.
   * This will normally be the result of a caller-specific check.
   * 
   * @param falseIfValid  a boolean resulting from testing an argument, may be null
   * @param message  the error message, not null
   * @param arg  the message arguments
   * @throws IllegalArgumentException if the test value is false
   */
  public static void isFalse(boolean falseIfValid, String message, Object... arg) {
    if (falseIfValid) {
      throw new IllegalArgumentException(MessageFormatter.arrayFormat(message, arg).getMessage());
    }
  }
  
  //-------------------------------------------------------------------------
  /**
   * Checks that the specified parameter is non-null.
   * 
   * @param parameter  the parameter to check, may be null
   * @param name  the name of the parameter to use in the error message, not null
   * @throws IllegalArgumentException if the input is null
   */
  public static void notNull(Object parameter, String name) {
    if (parameter == null) {
      throw new IllegalArgumentException("Input parameter '" + name + "' must not be null");
    }
  }

  /**
   * Checks that the specified injected parameter is non-null.
   * As a convention, the name of the parameter should be the exact name that you would
   * provide in a Spring configuration file.
   * 
   * @param parameter  the parameter to check, may be null
   * @param name  the name of the parameter to use in the error message, not null
   * @throws IllegalArgumentException if the input is null
   */
  public static void notNullInjected(Object parameter, String name) {
    if (parameter == null) {
      throw new IllegalArgumentException("Injected input parameter '" + name + "' must not be null");
{'fraction_non_alphanumeric': 0.11122688200052097, 'fraction_numerical': 0.0013024225058609013, 'mean_word_length': 2.716844143272023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5105710', 'n_tokens_mistral': 1943, 'n_tokens_neox': 1915, 'n_words': 845}