Class DefaultRequirements

java.lang.Object
com.github.cowwoc.requirements.DefaultRequirements

public final class DefaultRequirements extends Object
Verifies requirements using the default configuration. Any method that exposes a Requirements instance is returning an independent copy. Any modifications applied to that copy are thrown away and do not affect the configuration of this class.

To retain configuration changes, instantiate and reuse the same Requirements instance across multiple runs.

Thread-safety: This class is thread-safe.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Returns true if assertions are enabled for this class.
    static void
    Verifies requirements only if assertions are enabled.
    static <V> V
    Verifies requirements only if assertions are enabled.
    static Map<String,Object>
    Returns an unmodifiable map to append to the exception message.
    static String
    Returns the contextual information associated with this configuration.
    static boolean
    Indicates if stack trace references to this library should be removed.
    static boolean
    Indicates if exceptions should show the difference between the actual and expected values.
    static com.github.cowwoc.requirements.java.ArrayVerifier<boolean[],Boolean>
    requireThat(boolean[] actual, String name)
    Verifies the requirements of a primitive boolean array.
    static com.github.cowwoc.requirements.java.PrimitiveBooleanVerifier
    requireThat(boolean actual, String name)
    Verifies the requirements of a boolean.
    static com.github.cowwoc.requirements.java.ArrayVerifier<byte[],Byte>
    requireThat(byte[] actual, String name)
    Verifies the requirements of a primitive byte array.
    static com.github.cowwoc.requirements.java.PrimitiveNumberVerifier<Byte>
    requireThat(byte actual, String name)
    Verifies the requirements of a byte.
    static com.github.cowwoc.requirements.java.ArrayVerifier<char[],Character>
    requireThat(char[] actual, String name)
    Verifies the requirements of a primitive char array.
    static com.github.cowwoc.requirements.java.PrimitiveCharacterVerifier
    requireThat(char actual, String name)
    Verifies the requirements of a char.
    static com.github.cowwoc.requirements.java.ArrayVerifier<double[],Double>
    requireThat(double[] actual, String name)
    Verifies the requirements of a primitive double array.
    static com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier<Double>
    requireThat(double actual, String name)
    Verifies the requirements of a double.
    static com.github.cowwoc.requirements.java.ArrayVerifier<float[],Float>
    requireThat(float[] actual, String name)
    Verifies the requirements of a primitive float array.
    static com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier<Float>
    requireThat(float actual, String name)
    Verifies the requirements of a float.
    static com.github.cowwoc.requirements.java.ArrayVerifier<int[],Integer>
    requireThat(int[] actual, String name)
    Verifies the requirements of a primitive int array.
    static com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier<Integer>
    requireThat(int actual, String name)
    Verifies the requirements of an int.
    static com.github.cowwoc.requirements.java.ArrayVerifier<long[],Long>
    requireThat(long[] actual, String name)
    Verifies the requirements of a primitive long array.
    static com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier<Long>
    requireThat(long actual, String name)
    Verifies the requirements of a long.
    static com.github.cowwoc.requirements.java.ArrayVerifier<short[],Short>
    requireThat(short[] actual, String name)
    Verifies the requirements of a primitive short array.
    static com.github.cowwoc.requirements.java.PrimitiveNumberVerifier<Short>
    requireThat(short actual, String name)
    Verifies the requirements of a short.
    static <C extends Collection<E>, E>
    com.github.cowwoc.requirements.java.CollectionVerifier<C,E>
    requireThat(C actual, String name)
    Verifies the requirements of a Collection.
    static <E> com.github.cowwoc.requirements.java.ArrayVerifier<E[],E>
    requireThat(E[] actual, String name)
    Verifies the requirements of an Object array.
    static com.github.cowwoc.requirements.java.BooleanVerifier
    requireThat(Boolean actual, String name)
    Verifies the requirements of a Boolean.
    static <T> com.github.cowwoc.requirements.java.ClassVerifier<T>
    requireThat(Class<T> actual, String name)
    Verifies the requirements of a Class.
    static com.github.cowwoc.requirements.java.FloatingPointVerifier<Double>
    requireThat(Double actual, String name)
    Verifies the requirements of a Double.
    static com.github.cowwoc.requirements.java.FloatingPointVerifier<Float>
    requireThat(Float actual, String name)
    Verifies the requirements of a Float.
    static com.github.cowwoc.requirements.java.IntegerVerifier<Integer>
    requireThat(Integer actual, String name)
    Verifies the requirements of an Integer.
    static com.github.cowwoc.requirements.java.IntegerVerifier<Long>
    requireThat(Long actual, String name)
    Verifies the requirements of a Long.
    static com.github.cowwoc.requirements.java.StringVerifier
    requireThat(String actual, String name)
    Verifies the requirements of a String.
    static com.github.cowwoc.requirements.java.BigDecimalVerifier
    requireThat(BigDecimal actual, String name)
    Verifies the requirements of a BigDecimal.
    static com.github.cowwoc.requirements.java.InetAddressVerifier
    Verifies the requirements of an InetAddress.
    static com.github.cowwoc.requirements.java.UriVerifier
    requireThat(URI actual, String name)
    Verifies the requirements of a URI.
    static com.github.cowwoc.requirements.java.UrlVerifier
    requireThat(URL actual, String name)
    Verifies the requirements of a URL.
    static com.github.cowwoc.requirements.java.PathVerifier
    requireThat(Path actual, String name)
    Verifies the requirements of a Path.
    static <K, V> com.github.cowwoc.requirements.java.MapVerifier<K,V>
    requireThat(Map<K,V> actual, String name)
    Verifies the requirements of a Map.
    static com.github.cowwoc.requirements.java.OptionalVerifier
    requireThat(Optional<?> actual, String name)
    Verifies the requirements of an Optional.
    static <L extends List<E>, E>
    com.github.cowwoc.requirements.java.ListVerifier<L,E>
    requireThat(L actual, String name)
    Verifies the requirements of a List.
    static <T> com.github.cowwoc.requirements.java.ObjectVerifier<T>
    requireThat(T actual, String name)
    Verifies the requirements of an Object.
    static String
    Returns the String representation of an object.
    static com.github.cowwoc.requirements.java.ArrayValidator<boolean[],Boolean>
    validateThat(boolean[] actual, String name)
    Validates the requirements of a primitive boolean array.
    static com.github.cowwoc.requirements.java.PrimitiveBooleanValidator
    validateThat(boolean actual, String name)
    Validates the requirements of a boolean.
    static com.github.cowwoc.requirements.java.ArrayValidator<byte[],Byte>
    validateThat(byte[] actual, String name)
    Validates the requirements of a primitive byte array.
    static com.github.cowwoc.requirements.java.PrimitiveNumberValidator<Byte>
    validateThat(byte actual, String name)
    Validates the requirements of a byte.
    static com.github.cowwoc.requirements.java.ArrayValidator<char[],Character>
    validateThat(char[] actual, String name)
    Validates the requirements of a primitive char array.
    static com.github.cowwoc.requirements.java.PrimitiveCharacterValidator
    validateThat(char actual, String name)
    Validates the requirements of a char.
    static com.github.cowwoc.requirements.java.ArrayValidator<double[],Double>
    validateThat(double[] actual, String name)
    Validates the requirements of a primitive double array.
    static com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator<Double>
    validateThat(double actual, String name)
    Validates the requirements of a double.
    static com.github.cowwoc.requirements.java.ArrayValidator<float[],Float>
    validateThat(float[] actual, String name)
    Validates the requirements of a primitive float array.
    static com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator<Float>
    validateThat(float actual, String name)
    Validates the requirements of a float.
    static com.github.cowwoc.requirements.java.ArrayValidator<int[],Integer>
    validateThat(int[] actual, String name)
    Validates the requirements of a primitive int array.
    static com.github.cowwoc.requirements.java.PrimitiveIntegerValidator<Integer>
    validateThat(int actual, String name)
    Validates the requirements of an int.
    static com.github.cowwoc.requirements.java.ArrayValidator<long[],Long>
    validateThat(long[] actual, String name)
    Validates the requirements of a primitive long array.
    static com.github.cowwoc.requirements.java.PrimitiveIntegerValidator<Long>
    validateThat(long actual, String name)
    Validates the requirements of a long.
    static com.github.cowwoc.requirements.java.ArrayValidator<short[],Short>
    validateThat(short[] actual, String name)
    Validates the requirements of a primitive short array.
    static com.github.cowwoc.requirements.java.PrimitiveNumberValidator<Short>
    validateThat(short actual, String name)
    Validates the requirements of a short.
    static <C extends Collection<E>, E>
    com.github.cowwoc.requirements.java.CollectionValidator<C,E>
    validateThat(C actual, String name)
    Validates the requirements of a Collection.
    static <E> com.github.cowwoc.requirements.java.ArrayValidator<E[],E>
    validateThat(E[] actual, String name)
    Validates the requirements of an Object array.
    static com.github.cowwoc.requirements.java.BooleanValidator
    validateThat(Boolean actual, String name)
    Validates the requirements of a Boolean.
    static <T> com.github.cowwoc.requirements.java.ClassValidator<T>
    validateThat(Class<T> actual, String name)
    Validates the requirements of a Class.
    static com.github.cowwoc.requirements.java.FloatingPointValidator<Double>
    validateThat(Double actual, String name)
    Validates the requirements of a Double.
    static com.github.cowwoc.requirements.java.FloatingPointValidator<Float>
    validateThat(Float actual, String name)
    Validates the requirements of a Float.
    static com.github.cowwoc.requirements.java.IntegerValidator<Integer>
    validateThat(Integer actual, String name)
    Validates the requirements of an Integer.
    static com.github.cowwoc.requirements.java.IntegerValidator<Long>
    validateThat(Long actual, String name)
    Validates the requirements of a Long.
    static com.github.cowwoc.requirements.java.StringValidator
    validateThat(String actual, String name)
    Validates the requirements of a String.
    static com.github.cowwoc.requirements.java.BigDecimalValidator
    Validates the requirements of a BigDecimal.
    static com.github.cowwoc.requirements.java.InetAddressValidator
    Validates the requirements of an InetAddress.
    static com.github.cowwoc.requirements.java.UriValidator
    validateThat(URI actual, String name)
    Validates the requirements of a URI.
    static com.github.cowwoc.requirements.java.UrlValidator
    validateThat(URL actual, String name)
    Validates the requirements of a URL.
    static com.github.cowwoc.requirements.java.PathValidator
    validateThat(Path actual, String name)
    Validates the requirements of a Path.
    static <K, V> com.github.cowwoc.requirements.java.MapValidator<K,V>
    validateThat(Map<K,V> actual, String name)
    Validates the requirements of a Map.
    static com.github.cowwoc.requirements.java.OptionalValidator
    validateThat(Optional<?> actual, String name)
    Validates the requirements of an Optional.
    static <L extends List<E>, E>
    com.github.cowwoc.requirements.java.ListValidator<L,E>
    validateThat(L actual, String name)
    Validates the requirements of a List.
    static <T> com.github.cowwoc.requirements.java.ObjectValidator<T>
    validateThat(T actual, String name)
    Validates the requirements of an Object.
    Indicates that assertThat() shouldn't do anything.
    Indicates that assertThat() should verify requirements.
    Indicates that stack trace references to this library should be removed.
    withConfiguration(com.github.cowwoc.requirements.java.Configuration configuration)
    Replaces the configuration.
    withContext(String name, Object value)
    Adds or updates contextual information associated with the exception message.
    Indicates that exceptions should show the difference between the actual and expected values.
    Indicates that stack trace references to this library should be kept.
    Indicates that exceptions should not show the difference between the actual and expected values.
    static <T> Requirements
    Indicates that an object's toString() method should be used to convert it to a String.
    static <T> Requirements
    withStringConverter(Class<T> type, Function<T,String> converter)
    Indicates that a function should be used to convert an object to a String.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • assertionsAreEnabled

      public static boolean assertionsAreEnabled()
      Returns true if assertions are enabled for this class.
      Returns:
      true if assertions are enabled for this class
    • withAssertionsEnabled

      public static Requirements withAssertionsEnabled()
      Indicates that assertThat() should verify requirements.
      Returns:
      a new Requirements object that operates independently of the original instance
    • withAssertionsDisabled

      public static Requirements withAssertionsDisabled()
      Indicates that assertThat() shouldn't do anything.
      Returns:
      a new Requirements object that operates independently of the original instance
    • isDiffEnabled

      public static boolean isDiffEnabled()
      Indicates if exceptions should show the difference between the actual and expected values.
      Returns:
      true by default
    • withDiff

      public static Requirements withDiff()
      Indicates that exceptions should show the difference between the actual and expected values.
      Returns:
      a new Requirements object that operates independently of the original instance
    • withoutDiff

      public static Requirements withoutDiff()
      Indicates that exceptions should not show the difference between the actual and expected values.
      Returns:
      a new Requirements object that operates independently of the original instance
    • isCleanStackTrace

      public static boolean isCleanStackTrace()
      Indicates if stack trace references to this library should be removed.
      Returns:
      true by default
      See Also:
    • withCleanStackTrace

      public static Requirements withCleanStackTrace()
      Indicates that stack trace references to this library should be removed.
      Returns:
      a new Requirements object that operates independently of the original instance
      See Also:
    • withoutCleanStackTrace

      public static Requirements withoutCleanStackTrace()
      Indicates that stack trace references to this library should be kept.
      Returns:
      a new Requirements object that operates independently of the original instance
      See Also:
    • getContext

      public static Map<String,Object> getContext()
      Returns an unmodifiable map to append to the exception message.
      Returns:
      an empty map by default
      See Also:
    • withContext

      public static Requirements withContext(String name, Object value)
      Adds or updates contextual information associated with the exception message. Overrides any values associated with the name at the ThreadRequirements level.
      Parameters:
      name - the name of the parameter
      value - the value of the parameter
      Returns:
      a new Requirements object that operates independently of the original instance
      Throws:
      NullPointerException - if name is null
    • getContextMessage

      public static String getContextMessage(String message)
      Returns the contextual information associated with this configuration.
      Parameters:
      message - the exception message (null if absent)
      Returns:
      the contextual information associated with this configuration
    • toString

      public static String toString(Object value)
      Returns the String representation of an object. By default, custom handlers are provided for arrays, Integer, Long, BigDecimal, and Path.
      Parameters:
      value - a value
      Returns:
      the String representation of the value
      See Also:
    • withStringConverter

      public static <T> Requirements withStringConverter(Class<T> type, Function<T,String> converter)
      Indicates that a function should be used to convert an object to a String.

      Please note that type must be an exact match (e.g. configuring a converter for Set will not match values of type HashSet).

      Type Parameters:
      T - the type of object being converted
      Parameters:
      type - the type of object being converted (non-primitive arrays are mapped to Object[].class)
      converter - a function that converts an object of the specified type to a String
      Returns:
      a new Requirements object that operates independently of the original instance
      Throws:
      NullPointerException - if any of the arguments are null
    • withoutStringConverter

      public static <T> Requirements withoutStringConverter(Class<T> type)
      Indicates that an object's toString() method should be used to convert it to a String.
      Type Parameters:
      T - the type of object being converted
      Parameters:
      type - the type of object being converted
      Returns:
      a new Requirements object that operates independently of the original instance
      Throws:
      NullPointerException - if type is null
    • withConfiguration

      public static Requirements withConfiguration(com.github.cowwoc.requirements.java.Configuration configuration)
      Replaces the configuration.
      Parameters:
      configuration - a new configuration
      Returns:
      a new Requirements object that operates independently of the original instance
      Throws:
      NullPointerException - if configuration is null
    • assertThatAndReturn

      public static <V> V assertThatAndReturn(Function<Requirements,V> requirements)
      Verifies requirements only if assertions are enabled.
      Type Parameters:
      V - the return value of the operation
      Parameters:
      requirements - the requirements to verify
      Returns:
      the return value of the operation, or null if assertions are disabled
      Throws:
      NullPointerException - if requirements is null
      See Also:
    • assertThat

      public static void assertThat(Consumer<Requirements> requirements)
      Verifies requirements only if assertions are enabled.
      Parameters:
      requirements - the requirements to verify
      Throws:
      NullPointerException - if requirements is null
      See Also:
    • requireThat

      public static <T> com.github.cowwoc.requirements.java.ObjectVerifier<T> requireThat(T actual, String name)
      Verifies the requirements of an Object.
      Type Parameters:
      T - the type of the value
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static <T> com.github.cowwoc.requirements.java.ObjectValidator<T> validateThat(T actual, String name)
      Validates the requirements of an Object.
      Type Parameters:
      T - the type of the value
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static <C extends Collection<E>, E> com.github.cowwoc.requirements.java.CollectionVerifier<C,E> requireThat(C actual, String name)
      Verifies the requirements of a Collection.
      Type Parameters:
      C - the type of the collection
      E - the type of elements in the collection
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static <C extends Collection<E>, E> com.github.cowwoc.requirements.java.CollectionValidator<C,E> validateThat(C actual, String name)
      Validates the requirements of a Collection.
      Type Parameters:
      C - the type of the collection
      E - the type of elements in the collection
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static <L extends List<E>, E> com.github.cowwoc.requirements.java.ListVerifier<L,E> requireThat(L actual, String name)
      Verifies the requirements of a List.
      Type Parameters:
      L - the type of the list
      E - the type of elements in the list
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static <L extends List<E>, E> com.github.cowwoc.requirements.java.ListValidator<L,E> validateThat(L actual, String name)
      Validates the requirements of a List.
      Type Parameters:
      L - the type of the list
      E - the type of elements in the list
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.ArrayVerifier<byte[],Byte> requireThat(byte[] actual, String name)
      Verifies the requirements of a primitive byte array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.ArrayValidator<byte[],Byte> validateThat(byte[] actual, String name)
      Validates the requirements of a primitive byte array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.ArrayVerifier<short[],Short> requireThat(short[] actual, String name)
      Verifies the requirements of a primitive short array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.ArrayValidator<short[],Short> validateThat(short[] actual, String name)
      Validates the requirements of a primitive short array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.ArrayVerifier<int[],Integer> requireThat(int[] actual, String name)
      Verifies the requirements of a primitive int array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.ArrayValidator<int[],Integer> validateThat(int[] actual, String name)
      Validates the requirements of a primitive int array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.ArrayVerifier<long[],Long> requireThat(long[] actual, String name)
      Verifies the requirements of a primitive long array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.ArrayValidator<long[],Long> validateThat(long[] actual, String name)
      Validates the requirements of a primitive long array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.ArrayVerifier<float[],Float> requireThat(float[] actual, String name)
      Verifies the requirements of a primitive float array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.ArrayValidator<float[],Float> validateThat(float[] actual, String name)
      Validates the requirements of a primitive float array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.ArrayVerifier<double[],Double> requireThat(double[] actual, String name)
      Verifies the requirements of a primitive double array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.ArrayValidator<double[],Double> validateThat(double[] actual, String name)
      Validates the requirements of a primitive double array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.ArrayVerifier<boolean[],Boolean> requireThat(boolean[] actual, String name)
      Verifies the requirements of a primitive boolean array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.ArrayValidator<boolean[],Boolean> validateThat(boolean[] actual, String name)
      Validates the requirements of a primitive boolean array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.ArrayVerifier<char[],Character> requireThat(char[] actual, String name)
      Verifies the requirements of a primitive char array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.ArrayValidator<char[],Character> validateThat(char[] actual, String name)
      Validates the requirements of a primitive char array.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static <E> com.github.cowwoc.requirements.java.ArrayVerifier<E[],E> requireThat(E[] actual, String name)
      Verifies the requirements of an Object array.
      Type Parameters:
      E - the type of elements in the array
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static <E> com.github.cowwoc.requirements.java.ArrayValidator<E[],E> validateThat(E[] actual, String name)
      Validates the requirements of an Object array.
      Type Parameters:
      E - the type of elements in the array
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static <T extends Comparable<? super T>> com.github.cowwoc.requirements.java.ComparableVerifier<T> requireThat(T actual, String name)
      Verifies the requirements of a Comparable.
      Type Parameters:
      T - the type of objects that the value may be compared to
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static <T extends Comparable<? super T>> com.github.cowwoc.requirements.java.ComparableValidator<T> validateThat(T actual, String name)
      Validates the requirements of a Comparable.
      Type Parameters:
      T - the type of objects that the value may be compared to
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PrimitiveNumberVerifier<Byte> requireThat(byte actual, String name)
      Verifies the requirements of a byte.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PrimitiveNumberValidator<Byte> validateThat(byte actual, String name)
      Validates the requirements of a byte.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PrimitiveNumberVerifier<Short> requireThat(short actual, String name)
      Verifies the requirements of a short.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PrimitiveNumberValidator<Short> validateThat(short actual, String name)
      Validates the requirements of a short.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier<Integer> requireThat(int actual, String name)
      Verifies the requirements of an int.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PrimitiveIntegerValidator<Integer> validateThat(int actual, String name)
      Validates the requirements of an int.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.IntegerVerifier<Integer> requireThat(Integer actual, String name)
      Verifies the requirements of an Integer.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.IntegerValidator<Integer> validateThat(Integer actual, String name)
      Validates the requirements of an Integer.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier<Long> requireThat(long actual, String name)
      Verifies the requirements of a long.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PrimitiveIntegerValidator<Long> validateThat(long actual, String name)
      Validates the requirements of a long.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.IntegerVerifier<Long> requireThat(Long actual, String name)
      Verifies the requirements of a Long.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.IntegerValidator<Long> validateThat(Long actual, String name)
      Validates the requirements of a Long.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier<Float> requireThat(float actual, String name)
      Verifies the requirements of a float.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator<Float> validateThat(float actual, String name)
      Validates the requirements of a float.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier<Double> requireThat(double actual, String name)
      Verifies the requirements of a double.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator<Double> validateThat(double actual, String name)
      Validates the requirements of a double.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PrimitiveBooleanVerifier requireThat(boolean actual, String name)
      Verifies the requirements of a boolean.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PrimitiveBooleanValidator validateThat(boolean actual, String name)
      Validates the requirements of a boolean.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PrimitiveCharacterVerifier requireThat(char actual, String name)
      Verifies the requirements of a char.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PrimitiveCharacterValidator validateThat(char actual, String name)
      Validates the requirements of a char.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static <T extends Number & Comparable<? super T>> com.github.cowwoc.requirements.java.NumberVerifier<T> requireThat(T actual, String name)
      Verifies the requirements of a Number.
      Type Parameters:
      T - the type of the number
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static <T extends Number & Comparable<? super T>> com.github.cowwoc.requirements.java.NumberValidator<T> validateThat(T actual, String name)
      Validates the requirements of a Number.
      Type Parameters:
      T - the type of the number
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.BooleanVerifier requireThat(Boolean actual, String name)
      Verifies the requirements of a Boolean.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.BooleanValidator validateThat(Boolean actual, String name)
      Validates the requirements of a Boolean.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.FloatingPointVerifier<Float> requireThat(Float actual, String name)
      Verifies the requirements of a Float.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.FloatingPointValidator<Float> validateThat(Float actual, String name)
      Validates the requirements of a Float.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.FloatingPointVerifier<Double> requireThat(Double actual, String name)
      Verifies the requirements of a Double.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.FloatingPointValidator<Double> validateThat(Double actual, String name)
      Validates the requirements of a Double.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.BigDecimalVerifier requireThat(BigDecimal actual, String name)
      Verifies the requirements of a BigDecimal.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.BigDecimalValidator validateThat(BigDecimal actual, String name)
      Validates the requirements of a BigDecimal.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static <K, V> com.github.cowwoc.requirements.java.MapVerifier<K,V> requireThat(Map<K,V> actual, String name)
      Verifies the requirements of a Map.
      Type Parameters:
      K - the type of key in the map
      V - the type of value in the map
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static <K, V> com.github.cowwoc.requirements.java.MapValidator<K,V> validateThat(Map<K,V> actual, String name)
      Validates the requirements of a Map.
      Type Parameters:
      K - the type of key in the map
      V - the type of value in the map
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.PathVerifier requireThat(Path actual, String name)
      Verifies the requirements of a Path.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.PathValidator validateThat(Path actual, String name)
      Validates the requirements of a Path.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.StringVerifier requireThat(String actual, String name)
      Verifies the requirements of a String.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.StringValidator validateThat(String actual, String name)
      Validates the requirements of a String.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.UriVerifier requireThat(URI actual, String name)
      Verifies the requirements of a URI.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.UriValidator validateThat(URI actual, String name)
      Validates the requirements of a URI.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.UrlVerifier requireThat(URL actual, String name)
      Verifies the requirements of a URL.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.UrlValidator validateThat(URL actual, String name)
      Validates the requirements of a URL.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static <T> com.github.cowwoc.requirements.java.ClassVerifier<T> requireThat(Class<T> actual, String name)
      Verifies the requirements of a Class.
      Type Parameters:
      T - the type of class
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static <T> com.github.cowwoc.requirements.java.ClassValidator<T> validateThat(Class<T> actual, String name)
      Validates the requirements of a Class.
      Type Parameters:
      T - the type of class
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.OptionalVerifier requireThat(Optional<?> actual, String name)
      Verifies the requirements of an Optional.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.OptionalValidator validateThat(Optional<?> actual, String name)
      Validates the requirements of an Optional.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • requireThat

      public static com.github.cowwoc.requirements.java.InetAddressVerifier requireThat(InetAddress actual, String name)
      Verifies the requirements of an InetAddress.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a verifier for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank
    • validateThat

      public static com.github.cowwoc.requirements.java.InetAddressValidator validateThat(InetAddress actual, String name)
      Validates the requirements of an InetAddress.
      Parameters:
      actual - the actual value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is blank