java.lang.Object
com.github.cowwoc.requirements10.java.DefaultJavaValidators

public final class DefaultJavaValidators extends Object
Creates validators for the Java API.

There are three kinds of validators:

  • requireThat() for method preconditions.
  • assert that() for class invariants, and method postconditions.
  • checkIf() for returning multiple validation failures.

Thread Safety: This class is thread-safe.

  • Method Details

    • requireThat

      public static PrimitiveByteValidator requireThat(byte value, String name)
      Validates the state of a byte.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static ByteValidator requireThat(Byte value, String name)
      Validates the state of a Byte.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static PrimitiveShortValidator requireThat(short value, String name)
      Validates the state of a short.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static ShortValidator requireThat(Short value, String name)
      Validates the state of a Short.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static PrimitiveIntegerValidator requireThat(int value, String name)
      Validates the state of an int.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static IntegerValidator requireThat(Integer value, String name)
      Validates the state of an Integer.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static PrimitiveLongValidator requireThat(long value, String name)
      Validates the state of a long.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static LongValidator requireThat(Long value, String name)
      Validates the state of a Long.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static PrimitiveFloatValidator requireThat(float value, String name)
      Validates the state of a float.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static FloatValidator requireThat(Float value, String name)
      Validates the state of a Float.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static PrimitiveDoubleValidator requireThat(double value, String name)
      Validates the state of a double.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static DoubleValidator requireThat(Double value, String name)
      Validates the state of a Double.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • requireThat

      public static PrimitiveBooleanValidator requireThat(boolean value, String name)
      Validates the state of a boolean.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static BooleanValidator requireThat(Boolean value, String name)
      Validates the state of a Boolean.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveCharacterValidator requireThat(char value, String name)
      Validates the state of a char.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static CharacterValidator requireThat(Character value, String name)
      Validates the state of a Character.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static BigIntegerValidator requireThat(BigInteger value, String name)
      Validates the state of a BigInteger.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static BigDecimalValidator requireThat(BigDecimal value, String name)
      Validates the state of a BigDecimal.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static <T extends Comparable<T>> ComparableValidator<T> requireThat(T value, String name)
      Validates the state of a Comparable object.

      The returned validator throws an exception immediately if a validation fails.

      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static <T> ObjectValidator<T> requireThat(T value, String name)
      Validates the state of an Object.

      The returned validator throws an exception immediately if a validation fails.

      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static <T extends Collection<E>, E> CollectionValidator<T,E> requireThat(T value, String name)
      Validates the state of a Collection.

      The returned validator throws an exception immediately if a validation fails.

      Type Parameters:
      T - the type of the value
      E - the type of elements in the collection
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static <T extends List<E>, E> ListValidator<T,E> requireThat(T value, String name)
      Validates the state of a List.

      The returned validator throws an exception immediately if a validation fails.

      Type Parameters:
      T - the type of the value
      E - the type of elements in the list
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveByteArrayValidator requireThat(byte[] value, String name)
      Validates the state of a primitive byte array.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveShortArrayValidator requireThat(short[] value, String name)
      Validates the state of a primitive short array.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveIntegerArrayValidator requireThat(int[] value, String name)
      Validates the state of a primitive int array.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveLongArrayValidator requireThat(long[] value, String name)
      Validates the state of a primitive long array.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveFloatArrayValidator requireThat(float[] value, String name)
      Validates the state of a primitive float array.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveDoubleArrayValidator requireThat(double[] value, String name)
      Validates the state of a primitive double array.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveBooleanArrayValidator requireThat(boolean[] value, String name)
      Validates the state of a primitive boolean array.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PrimitiveCharacterArrayValidator requireThat(char[] value, String name)
      Validates the state of a primitive char array.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static <E> ObjectArrayValidator<E[],E> requireThat(E[] value, String name)
      Validates the state of an Object array.

      The returned validator throws an exception immediately if a validation fails.

      Type Parameters:
      E - the type of elements in the array
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static <T extends Map<K, V>, K, V> MapValidator<T,K,V> requireThat(T value, String name)
      Validates the state of a Map.

      The returned validator throws an exception immediately if a validation fails.

      Type Parameters:
      T - the type of the map
      K - the type of keys in the map
      V - the type of values in the map
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static PathValidator requireThat(Path value, String name)
      Validates the state of a Path.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static StringValidator requireThat(String value, String name)
      Validates the state of a String.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static UriValidator requireThat(URI value, String name)
      Validates the state of a URI.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static <T> GenericTypeValidator<T> requireThat(Class<T> value, String name)
      Validates the state of a Class.

      The returned validator throws an exception immediately if a validation fails.

      Type Parameters:
      T - the type of the class modelled by the Class object
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static <T> OptionalValidator<T> requireThat(Optional<T> value, String name)
      Validates the state of an Optional.

      The returned validator throws an exception immediately if a validation fails.

      Type Parameters:
      T - the type of optional
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • requireThat

      public static InetAddressValidator requireThat(InetAddress value, String name)
      Validates the state of an InetAddress.

      The returned validator throws an exception immediately if a validation fails.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveByteValidator that(byte value, String name)
      Validates the state of a byte.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveByteValidator that(byte value)
      Validates the state of a byte.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static ByteValidator that(Byte value, String name)
      Validates the state of a Byte.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static ByteValidator that(Byte value)
      Validates the state of a Byte.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveShortValidator that(short value, String name)
      Validates the state of a short.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveShortValidator that(short value)
      Validates the state of a short.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static ShortValidator that(Short value, String name)
      Validates the state of a Short.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static ShortValidator that(Short value)
      Validates the state of a Short.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveIntegerValidator that(int value, String name)
      Validates the state of an int.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveIntegerValidator that(int value)
      Validates the state of an int.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static IntegerValidator that(Integer value, String name)
      Validates the state of an Integer.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static IntegerValidator that(Integer value)
      Validates the state of an Integer.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveLongValidator that(long value, String name)
      Validates the state of a long.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveLongValidator that(long value)
      Validates the state of a long.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static LongValidator that(Long value, String name)
      Validates the state of a Long.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static LongValidator that(Long value)
      Validates the state of a Long.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveFloatValidator that(float value, String name)
      Validates the state of a float.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveFloatValidator that(float value)
      Validates the state of a float.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static FloatValidator that(Float value, String name)
      Validates the state of a Float.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static FloatValidator that(Float value)
      Validates the state of a Float.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveDoubleValidator that(double value, String name)
      Validates the state of a double.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveDoubleValidator that(double value)
      Validates the state of a double.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static DoubleValidator that(Double value, String name)
      Validates the state of a Double.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static DoubleValidator that(Double value)
      Validates the state of a Double.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveBooleanValidator that(boolean value, String name)
      Validates the state of a boolean.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveBooleanValidator that(boolean value)
      Validates the state of a boolean.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static BooleanValidator that(Boolean value, String name)
      Validates the state of a Boolean.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static BooleanValidator that(Boolean value)
      Validates the state of a Boolean.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveCharacterValidator that(char value, String name)
      Validates the state of a char.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveCharacterValidator that(char value)
      Validates the state of a char.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static CharacterValidator that(Character value, String name)
      Validates the state of a Character.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static CharacterValidator that(Character value)
      Validates the state of a Character.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static BigIntegerValidator that(BigInteger value, String name)
      Validates the state of a BigInteger.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static BigIntegerValidator that(BigInteger value)
      Validates the state of a BigInteger.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static BigDecimalValidator that(BigDecimal value, String name)
      Validates the state of a BigDecimal.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static BigDecimalValidator that(BigDecimal value)
      Validates the state of a BigDecimal.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static <T extends Comparable<T>> ComparableValidator<T> that(T value, String name)
      Validates the state of a Comparable object.
      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static <T extends Comparable<T>> ComparableValidator<T> that(T value)
      Validates the state of a Comparable object.
      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static <T> ObjectValidator<T> that(T value, String name)
      Validates the state of an Object.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of value
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static <T> ObjectValidator<T> that(T value)
      Validates the state of an Object.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of value
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static <T extends Collection<E>, E> CollectionValidator<T,E> that(T value, String name)
      Validates the state of a Collection.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of the value
      E - the type of elements in the collection
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static <T extends Collection<E>, E> CollectionValidator<T,E> that(T value)
      Validates the state of a Collection.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of the value
      E - the type of elements in the collection
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static <T extends List<E>, E> ListValidator<T,E> that(T value, String name)
      Validates the state of a List.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of the value
      E - the type of elements in the list
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static <T extends List<E>, E> ListValidator<T,E> that(T value)
      Validates the state of a List.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of the value
      E - the type of elements in the list
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveByteArrayValidator that(byte[] value, String name)
      Validates the state of a primitive byte array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveByteArrayValidator that(byte[] value)
      Validates the state of a primitive byte array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveShortArrayValidator that(short[] value, String name)
      Validates the state of a primitive short array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveShortArrayValidator that(short[] value)
      Validates the state of a primitive short array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveIntegerArrayValidator that(int[] value, String name)
      Validates the state of a primitive int array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveIntegerArrayValidator that(int[] value)
      Validates the state of a primitive int array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveLongArrayValidator that(long[] value, String name)
      Validates the state of a primitive long array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveLongArrayValidator that(long[] value)
      Validates the state of a primitive long array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveFloatArrayValidator that(float[] value, String name)
      Validates the state of a primitive float array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveFloatArrayValidator that(float[] value)
      Validates the state of a primitive float array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveDoubleArrayValidator that(double[] value, String name)
      Validates the state of a primitive double array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveDoubleArrayValidator that(double[] value)
      Validates the state of a primitive double array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PrimitiveBooleanArrayValidator that(boolean[] value, String name)
      Validates the state of a primitive boolean array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveBooleanArrayValidator that(boolean[] value)
      Validates the state of a primitive boolean array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveCharacterArrayValidator that(char[] value, String name)
      Validates the state of a primitive char array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PrimitiveCharacterArrayValidator that(char[] value)
      Validates the state of a primitive char array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static <E> ObjectArrayValidator<E[],E> that(E[] value, String name)
      Validates the state of an Object array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      E - the type of elements in the array
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static <E> ObjectArrayValidator<E[],E> that(E[] value)
      Validates the state of an Object array.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      E - the type of elements in the array
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static <T extends Map<K, V>, K, V> MapValidator<T,K,V> that(T value, String name)
      Validates the state of a Map.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of the map
      K - the type of keys in the map
      V - the type of values in the map
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static <T extends Map<K, V>, K, V> MapValidator<T,K,V> that(T value)
      Validates the state of a Map.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of the map
      K - the type of keys in the map
      V - the type of values in the map
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static PathValidator that(Path value, String name)
      Validates the state of a Path.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static PathValidator that(Path value)
      Validates the state of a Path.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static StringValidator that(String value, String name)
      Validates the state of a String.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static StringValidator that(String value)
      Validates the state of a String.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static UriValidator that(URI value, String name)
      Validates the state of a URI.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static UriValidator that(URI value)
      Validates the state of a URI.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static <T> GenericTypeValidator<T> that(Class<T> value, String name)
      Validates the state of a Class.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of the class modelled by the Class object
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static <T> GenericTypeValidator<T> that(Class<T> value)
      Validates the state of a Class.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of the class modelled by the Class object
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static <T> OptionalValidator<T> that(Optional<T> value, String name)
      Validates the state of an Optional.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of optional
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static <T> OptionalValidator<T> that(Optional<T> value)
      Validates the state of an Optional.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Type Parameters:
      T - the type of optional
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • that

      public static InetAddressValidator that(InetAddress value, String name)
      Validates the state of an InetAddress.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • that

      public static InetAddressValidator that(InetAddress value)
      Validates the state of an InetAddress.

      The returned validator throws an exception immediately if a validation fails. This exception is then converted into an AssertionError. Exceptions unrelated to validation failures are not converted.

      This method is intended to be used with the assert keyword, like so: assert that(value, name).

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveByteValidator checkIf(byte value, String name)
      Validates the state of a byte.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveByteValidator checkIf(byte value)
      Validates the state of a byte

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static ByteValidator checkIf(Byte value, String name)
      Validates the state of a Byte

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static ByteValidator checkIf(Byte value)
      Validates the state of a Byte

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveShortValidator checkIf(short value, String name)
      Validates the state of a short

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace, or is empty
    • checkIf

      public static PrimitiveShortValidator checkIf(short value)
      Validates the state of a short

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static ShortValidator checkIf(Short value, String name)
      Validates the state of a Short

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static ShortValidator checkIf(Short value)
      Validates the state of a Short

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveIntegerValidator checkIf(int value, String name)
      Validates the state of an int

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveIntegerValidator checkIf(int value)
      Validates the state of an int

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static IntegerValidator checkIf(Integer value, String name)
      Validates the state of an Integer

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static IntegerValidator checkIf(Integer value)
      Validates the state of an Integer

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveLongValidator checkIf(long value, String name)
      Validates the state of a long

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveLongValidator checkIf(long value)
      Validates the state of a long

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static LongValidator checkIf(Long value, String name)
      Validates the state of a Long

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static LongValidator checkIf(Long value)
      Validates the state of a Long

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveFloatValidator checkIf(float value, String name)
      Validates the state of a float

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveFloatValidator checkIf(float value)
      Validates the state of a float

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static FloatValidator checkIf(Float value, String name)
      Validates the state of a Float

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static FloatValidator checkIf(Float value)
      Validates the state of a Float

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveDoubleValidator checkIf(double value, String name)
      Validates the state of a double

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveDoubleValidator checkIf(double value)
      Validates the state of a double

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static DoubleValidator checkIf(Double value, String name)
      Validates the state of a Double

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static DoubleValidator checkIf(Double value)
      Validates the state of a Double

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveBooleanValidator checkIf(boolean value, String name)
      Validates the state of a boolean

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveBooleanValidator checkIf(boolean value)
      Validates the state of a boolean

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static BooleanValidator checkIf(Boolean value, String name)
      Validates the state of a Boolean

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static BooleanValidator checkIf(Boolean value)
      Validates the state of a Boolean

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveCharacterValidator checkIf(char value, String name)
      Validates the state of a char

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveCharacterValidator checkIf(char value)
      Validates the state of a char

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static CharacterValidator checkIf(Character value, String name)
      Validates the state of a Character

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static CharacterValidator checkIf(Character value)
      Validates the state of a Character

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static BigIntegerValidator checkIf(BigInteger value, String name)
      Validates the state of a BigInteger

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static BigIntegerValidator checkIf(BigInteger value)
      Validates the state of a BigInteger

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static BigDecimalValidator checkIf(BigDecimal value, String name)
      Validates the state of a BigDecimal

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static BigDecimalValidator checkIf(BigDecimal value)
      Validates the state of a BigDecimal

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static <T extends Comparable<T>> ComparableValidator<T> checkIf(T value, String name)
      Validates the state of a Comparable object.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static <T extends Comparable<T>> ComparableValidator<T> checkIf(T value)
      Validates the state of a Comparable object.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static <T> ObjectValidator<T> checkIf(T value, String name)
      Validates the state of an Object

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static <T> ObjectValidator<T> checkIf(T value)
      Validates the state of an Object

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the value
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static <T extends Collection<E>, E> CollectionValidator<T,E> checkIf(T value, String name)
      Validates the state of a Collection

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the value
      E - the type of elements in the collection
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static <T extends Collection<E>, E> CollectionValidator<T,E> checkIf(T value)
      Validates the state of a Collection

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the value
      E - the type of elements in the collection
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static <T extends List<E>, E> ListValidator<T,E> checkIf(T value, String name)
      Validates the state of a List

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the value
      E - the type of elements in the list
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static <T extends List<E>, E> ListValidator<T,E> checkIf(T value)
      Validates the state of a List

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the value
      E - the type of elements in the list
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveByteArrayValidator checkIf(byte[] value, String name)
      Validates the state of a primitive byte array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveByteArrayValidator checkIf(byte[] value)
      Validates the state of a primitive byte array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveShortArrayValidator checkIf(short[] value, String name)
      Validates the state of a primitive short array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveShortArrayValidator checkIf(short[] value)
      Validates the state of a primitive short array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveIntegerArrayValidator checkIf(int[] value, String name)
      Validates the state of a primitive int array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveIntegerArrayValidator checkIf(int[] value)
      Validates the state of a primitive int array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveLongArrayValidator checkIf(long[] value, String name)
      Validates the state of a primitive long array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveLongArrayValidator checkIf(long[] value)
      Validates the state of a primitive long array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveFloatArrayValidator checkIf(float[] value, String name)
      Validates the state of a primitive float array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveFloatArrayValidator checkIf(float[] value)
      Validates the state of a primitive float array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveDoubleArrayValidator checkIf(double[] value, String name)
      Validates the state of a primitive double array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveDoubleArrayValidator checkIf(double[] value)
      Validates the state of a primitive double array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveBooleanArrayValidator checkIf(boolean[] value, String name)
      Validates the state of a primitive boolean array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveBooleanArrayValidator checkIf(boolean[] value)
      Validates the state of a primitive boolean array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PrimitiveCharacterArrayValidator checkIf(char[] value, String name)
      Validates the state of a primitive char array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PrimitiveCharacterArrayValidator checkIf(char[] value)
      Validates the state of a primitive char array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static <E> ObjectArrayValidator<E[],E> checkIf(E[] value, String name)
      Validates the state of an Object array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      E - the type of elements in the array
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static <E> ObjectArrayValidator<E[],E> checkIf(E[] value)
      Validates the state of an Object array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      E - the type of elements in the array
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static <T extends Map<K, V>, K, V> MapValidator<T,K,V> checkIf(T value, String name)
      Validates the state of a Map.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the map
      K - the type of keys in the map
      V - the type of values in the map
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static <T extends Map<K, V>, K, V> MapValidator<T,K,V> checkIf(T value)
      Validates the state of a Map.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the map
      K - the type of keys in the map
      V - the type of values in the map
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static PathValidator checkIf(Path value, String name)
      Validates the state of a Path.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static PathValidator checkIf(Path value)
      Validates the state of a Path.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static StringValidator checkIf(String value, String name)
      Validates the state of a String.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static StringValidator checkIf(String value)
      Validates the state of a String.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static UriValidator checkIf(URI value, String name)
      Validates the state of a URI.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static UriValidator checkIf(URI value)
      Validates the state of a URI.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static <T> GenericTypeValidator<T> checkIf(Class<T> value, String name)
      Validates the state of a Class.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the class modelled by the Class object
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static <T> GenericTypeValidator<T> checkIf(Class<T> value)
      Validates the state of a Class.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the class modelled by the Class object
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static <T> OptionalValidator<T> checkIf(Optional<T> value, String name)
      Validates the state of an Optional.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the class modelled by the Class object
      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static <T> OptionalValidator<T> checkIf(Optional<T> value)
      Validates the state of an Optional.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters:
      T - the type of the class modelled by the Class object
      Parameters:
      value - the value
      Returns:
      a validator for the value
    • checkIf

      public static InetAddressValidator checkIf(InetAddress value, String name)
      Validates the state of an InetAddress.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      name - the name of the value
      Returns:
      a validator for the value
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name contains whitespace or is empty
    • checkIf

      public static InetAddressValidator checkIf(InetAddress value)
      Validates the state of an InetAddress.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. These exceptions can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Parameters:
      value - the value
      Returns:
      a validator for the value
    • getContext

      public static Map<String,Optional<Object>> getContext()
      Returns the contextual information for validators created out by this factory. The contextual information is a map of key-value pairs that can provide more details about validation failures. For example, if the message is "Password may not be empty" and the map contains the key-value pair {"username": "john.smith"}, the exception message would be:

      Password may not be empty
      username: john.smith

      Note that values are wrapped in an Optional because modern maps do not support null values.

      Returns:
      an unmodifiable map from each entry's name to its value
    • withContext

      public static JavaValidators withContext(Object value, String name)
      Sets the contextual information for validators created by this factory.

      This method adds contextual information to exception messages. The contextual information is stored as key-value pairs in a map. Values set by this method may be overridden by ValidatorComponent.withContext(Object, String)}.

      Parameters:
      value - the value of the entry
      name - the name of an entry
      Returns:
      the underlying validator factory
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name:
      • contains whitespace
      • is empty
      • is already in use by the value being validated or the validator context
    • removeContext

      public static JavaValidators removeContext(String name)
      Removes the contextual information of validators created by this factory.
      Parameters:
      name - the parameter name
      Returns:
      the underlying validator factory
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name:
      • contains whitespace
      • is empty
    • globalConfiguration

      public static GlobalConfiguration globalConfiguration()
      Returns the global configuration shared by all validators.

      NOTE: Updating this configuration affects existing and new validators.

      Returns:
      the global configuration updater