gov.sandia.cognition.util
Class ArgumentChecker

java.lang.Object
  extended by gov.sandia.cognition.util.ArgumentChecker

public class ArgumentChecker
extends Object

A utility class for checking arguments to a function. If the constraint is violated, then an IllegalArgumentException is thrown.

Since:
3.1
Author:
Justin Basilico

Constructor Summary
ArgumentChecker()
           
 
Method Summary
static void assertIsInRangeExclusive(String argument, double value, double lowerBound, double upperBound)
          Asserts that the given argument is in the given range, exclusive.
static void assertIsInRangeInclusive(String argument, double value, double lowerBound, double upperBound)
          Asserts that the given argument is in the given range, inclusive.
static void assertIsNonNegative(String argument, double value)
          Asserts that the given argument is non-negative (>=0.0).
static void assertIsNonNegative(String argument, int value)
          Asserts that the given argument is non-negative (>=0.0).
static void assertIsNonNegative(String argument, long value)
          Asserts that the given argument is non-negative (>=0.0).
static void assertIsNotNull(String argument, Object value)
          Asserts that the given value is not null.
static void assertIsPositive(String argument, double value)
          Asserts the given value is positive (> 0.0).
static void assertIsPositive(String argument, int value)
          Asserts the given value is positive (> 0).
static void assertIsPositive(String argument, long value)
          Asserts the given value is positive (> 0).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArgumentChecker

public ArgumentChecker()
Method Detail

assertIsNotNull

public static void assertIsNotNull(String argument,
                                   Object value)
Asserts that the given value is not null. If the assertion is violated, an IllegalArgumentException is thrown.

Parameters:
argument - The name of the argument.
value - The value of the argument.

assertIsPositive

public static void assertIsPositive(String argument,
                                    int value)
Asserts the given value is positive (> 0). If the assertion is violated, an IllegalArgumentException is thrown.

Parameters:
argument - The name of the argument.
value - The value of the argument.

assertIsPositive

public static void assertIsPositive(String argument,
                                    long value)
Asserts the given value is positive (> 0). If the assertion is violated, an IllegalArgumentException is thrown.

Parameters:
argument - The name of the argument.
value - The value of the argument.

assertIsPositive

public static void assertIsPositive(String argument,
                                    double value)
Asserts the given value is positive (> 0.0). If the assertion is violated, an IllegalArgumentException is thrown. NaNs fail the assertion.

Parameters:
argument - The name of the argument.
value - The value of the argument.

assertIsNonNegative

public static void assertIsNonNegative(String argument,
                                       int value)
Asserts that the given argument is non-negative (>=0.0). If the assertion is violated, an IllegalArgumentException is thrown.

Parameters:
argument - The name of the argument.
value - The value of the argument.

assertIsNonNegative

public static void assertIsNonNegative(String argument,
                                       long value)
Asserts that the given argument is non-negative (>=0.0). If the assertion is violated, an IllegalArgumentException is thrown. NaNs fail the assertion.

Parameters:
argument - The name of the argument.
value - The value of the argument.

assertIsNonNegative

public static void assertIsNonNegative(String argument,
                                       double value)
Asserts that the given argument is non-negative (>=0.0). If the assertion is violated, an IllegalArgumentException is thrown.

Parameters:
argument - The name of the argument.
value - The value of the argument.

assertIsInRangeInclusive

public static void assertIsInRangeInclusive(String argument,
                                            double value,
                                            double lowerBound,
                                            double upperBound)
Asserts that the given argument is in the given range, inclusive. If the assertion is violated, an IllegalArgumentException is thrown. NaNs are treated as outside of the range.

Parameters:
argument - The name of the argument.
value - The value of the argument.
lowerBound - The lower bound of the value (inclusive).
upperBound - The upper bound of the value (inclusive).

assertIsInRangeExclusive

public static void assertIsInRangeExclusive(String argument,
                                            double value,
                                            double lowerBound,
                                            double upperBound)
Asserts that the given argument is in the given range, exclusive. If the assertion is violated, an IllegalArgumentException is thrown. NaNs are treated as outside of the range.

Parameters:
argument - The name of the argument.
value - The value of the argument.
lowerBound - The lower bound of the value (exclusive).
upperBound - The upper bound of the value (exclusive).