Class IntCheck<X extends Exception>

java.lang.Object
org.klojang.check.IntCheck<X>
Type Parameters:
X - The type of the exception that is thrown by default if the value fails a test (this can be overridden for individual tests in the chain of checks)

public final class IntCheck<X extends Exception> extends Object
Facilitates the validation of int values. See the module summary for a detailed explanation.
  • Method Details

    • ok

      public int ok()
      Returns the int value validated by this instance. To be used as the last call after a chain of checks.
      Returns:
      the int value validated by this instance
    • ok

      public <X2 extends Throwable> int ok(FallibleIntUnaryOperator<X2> transformer) throws X2
      Passes the validated value to the specified function and returns the value it computes. To be used as the last call after a chain of checks. For example:
      
       int moderate = Check.that(t, "temperature").has(abs(), lt(), 30).ok(Math::abs);
       
      Type Parameters:
      X2 - the type of the exception thrown if the transformation fails
      Parameters:
      transformer - a function that transforms the int value validated by this instance
      Returns:
      the value computed by the transformation function
      Throws:
      X2 - if the transformation fails
    • mapToObj

      public <R, X2 extends Throwable> R mapToObj(FallibleIntFunction<R,X2> transformer) throws X2
      Passes the validated value to the specified function and returns the value it computes. To be used as the last call after a chain of checks.
      
       List<String> list = ...;
       String s = Check.that(index).is(indexOf(), list).ok(list::get);
       
      Type Parameters:
      R - the type of the returned value
      X2 - the type of the exception thrown if the transformation fails
      Parameters:
      transformer - a function that transforms the int value validated by this instance
      Returns:
      the value computed by the Function
      Throws:
      X2 - if the transformation fails
    • then

      public <X2 extends Throwable> void then(FallibleIntConsumer<X2> consumer) throws X2
      Passes the validated value to a consumer for further processing. To be used as the last call after a chain of checks.
      Type Parameters:
      X2 - the type of the exception thrown if the consumer fails while processing the value
      Parameters:
      consumer - a consumer of the int value validated by this instance
      Throws:
      X2 - if the consumer fails while processing the value
    • is

      public IntCheck<X> is(IntPredicate test) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from the CommonChecks class. When providing your own lambda or method reference, the error message wil not be very intelligible.
      Parameters:
      test - the test
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • isNot

      public IntCheck<X> isNot(IntPredicate test) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from the CommonChecks class. When providing your own lambda or method reference, the error message wil not be very intelligible.
      Parameters:
      test - the test
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • is

      public IntCheck<X> is(IntPredicate test, String message, Object... msgArgs) throws X
      Validates the argument using the specified test. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Parameters:
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • isNot

      public IntCheck<X> isNot(IntPredicate test, String message, Object... msgArgs) throws X
      Validates the argument using the specified test. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Parameters:
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • is

      public <X2 extends Exception> IntCheck<X> is(IntPredicate test, Supplier<X2> exception) throws X2
      Validates the argument using the specified test. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      X2 - the type of the exception thrown if the int value does not pass the test
      Parameters:
      test - the test
      exception - the supplier of the exception to be thrown if the argument is invalid The Supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the int value does not pass the test
    • isNot

      public <X2 extends Exception> IntCheck<X> isNot(IntPredicate test, Supplier<X2> exception) throws X2
      Validates the argument using the specified test. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      X2 - the type of the exception thrown if the int value does not pass the test
      Parameters:
      test - the test
      exception - the supplier of the exception to be thrown if the argument is invalid The Supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the int value does not pass the test
    • is

      public IntCheck<X> is(IntRelation test, int object) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from the CommonChecks class. When providing your own lambda or method reference, the error message wil not be very intelligible.
      Parameters:
      test - the test
      object - the object of the Relation
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • isNot

      public IntCheck<X> isNot(IntRelation test, int object) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from the CommonChecks class. When providing your own lambda or method reference, the error message wil not be very intelligible.
      Parameters:
      test - the test
      object - the object of the Relation
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • is

      public IntCheck<X> is(IntRelation test, int object, String message, Object... msgArgs) throws X
      Validates the argument using the specified test. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • isNot

      public IntCheck<X> isNot(IntRelation test, int object, String message, Object... msgArgs) throws X
      Validates the argument using the specified test. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • is

      public <X2 extends Exception> IntCheck<X> is(IntRelation test, int object, Supplier<X2> exception) throws X2
      Validates the argument using the specified test. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      X2 - the type of the exception thrown if the int value does not pass the test
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      exception - the supplier of the exception to be thrown if the argument is invalid The Supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the int value does not pass the test
    • isNot

      public <X2 extends Exception> IntCheck<X> isNot(IntRelation test, int object, Supplier<X2> exception) throws X2
      Validates the argument using the specified test. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      X2 - the type of the exception thrown if the int value does not pass the test
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      exception - the supplier of the exception to be thrown if the argument is invalid The Supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the int value does not pass the test
    • is

      public <O> IntCheck<X> is(IntObjRelation<O> test, O object) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from the CommonChecks class. When providing your own lambda or method reference, the error message wil not be very intelligible.
      Type Parameters:
      O - The type of the object of the IntObjRelation
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • isNot

      public <O> IntCheck<X> isNot(IntObjRelation<O> test, O object) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from the CommonChecks class. When providing your own lambda or method reference, the error message wil not be very intelligible.
      Type Parameters:
      O - the type of the object of the IntObjRelation
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • is

      public <O> IntCheck<X> is(IntObjRelation<O> test, O object, String message, Object... msgArgs) throws X
      Validates the argument using the specified test. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Type Parameters:
      O - the type of the object of the IntObjRelation
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • isNot

      public <O> IntCheck<X> isNot(IntObjRelation<O> test, O object, String message, Object... msgArgs) throws X
      Validates the argument using the specified test. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Type Parameters:
      O - the type of the object of the IntObjRelation
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the int value does not pass the test
    • is

      public <O, X2 extends Exception> IntCheck<X> is(IntObjRelation<O> test, O object, Supplier<X2> exception) throws X2
      Validates the argument using the specified test. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      O - the type of the object of the IntObjRelation
      X2 - the type of exception thrown if the int value does not pass the test
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      exception - the supplier of the exception to be thrown if the argument is invalid The Supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the int value does not pass the test
    • isNot

      public <O, X2 extends Exception> IntCheck<X> isNot(IntObjRelation<O> test, O object, Supplier<X2> exception) throws X2
      Validates the argument using the specified test. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      O - the type of the object of the IntObjRelation
      X2 - the type of exception thrown if the int value does not pass the test
      Parameters:
      test - the test
      object - the object of the IntObjRelation
      exception - the supplier of the exception to be thrown if the argument is invalid The Supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the int value does not pass the test
    • has

      public <P> IntCheck<X> has(IntFunction<P> property, Predicate<P> test) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public <P> IntCheck<X> notHas(IntFunction<P> property, Predicate<P> test) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public <P> IntCheck<X> has(IntFunction<P> property, String name, Predicate<P> test) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      name - The name of the property being tested.
      test - the test
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public <P> IntCheck<X> notHas(IntFunction<P> property, String name, Predicate<P> test) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      name - The name of the property being tested.
      test - the test
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public <P> IntCheck<X> has(IntFunction<P> property, Predicate<P> test, String message, Object... msgArgs) throws X
      Validates a property of the argument. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public <P> IntCheck<X> notHas(IntFunction<P> property, Predicate<P> test, String message, Object... msgArgs) throws X
      Validates a property of the argument. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public <P, X2 extends Exception> IntCheck<X> has(IntFunction<P> property, Predicate<P> test, Supplier<X2> exception) throws X2
      Validates a property of the argument. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      P - the type of the extracted value
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      exception - the supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the argument is invalid
    • notHas

      public <P, X2 extends Exception> IntCheck<X> notHas(IntFunction<P> property, Predicate<P> test, Supplier<X2> exception) throws X2
      Validates a property of the argument. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      P - the type of the extracted value
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      exception - the supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the argument is invalid
    • has

      public <P, O> IntCheck<X> has(IntFunction<P> property, Relation<P,O> test, O object) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public <P, O> IntCheck<X> notHas(IntFunction<P> property, Relation<P,O> test, O object) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public <P, O> IntCheck<X> has(IntFunction<P> property, String name, Relation<P,O> test, O object) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      name - The name of the property being tested.
      test - the test
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public <P, O> IntCheck<X> notHas(IntFunction<P> property, String name, Relation<P,O> test, O object) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      name - The name of the property being tested.
      test - the test
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public <P, O> IntCheck<X> has(IntFunction<P> property, Relation<P,O> test, O object, String message, Object... msgArgs) throws X
      Validates a property of the argument. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the value that the argument is tested against (called "the object" of a relation)
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public <P, O> IntCheck<X> notHas(IntFunction<P> property, Relation<P,O> test, O object, String message, Object... msgArgs) throws X
      Validates a property of the argument. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the value that the argument is tested against (called "the object" of a relation)
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public <P, O, X2 extends Exception> IntCheck<X> has(IntFunction<P> property, Relation<P,O> test, O object, Supplier<X2> exception) throws X2
      Validates a property of the argument. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the value that the argument is tested against (called "the object" of a relation)
      exception - the supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the argument is invalid
    • notHas

      public <P, O, X2 extends Exception> IntCheck<X> notHas(IntFunction<P> property, Relation<P,O> test, O object, Supplier<X2> exception) throws X2
      Validates a property of the argument. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the value that the argument is tested against (called "the object" of a relation)
      exception - the supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the argument is invalid
    • has

      public IntCheck<X> has(IntUnaryOperator property, IntPredicate test) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public IntCheck<X> notHas(IntUnaryOperator property, IntPredicate test) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public IntCheck<X> has(IntUnaryOperator property, String name, IntPredicate test) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      name - The name of the property being tested. In error messages the fully-qualified name will be used and constructed using argName + "." + name.
      test - the test
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public IntCheck<X> notHas(IntUnaryOperator property, String name, IntPredicate test) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      name - The name of the property being tested. In error messages the fully-qualified name will be used and constructed using argName + "." + name.
      test - the test
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public IntCheck<X> has(IntUnaryOperator property, IntPredicate test, String message, Object... msgArgs) throws X
      Validates a property of the argument. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public IntCheck<X> notHas(IntUnaryOperator property, IntPredicate test, String message, Object... msgArgs) throws X
      Validates a property of the argument. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public <X2 extends Exception> IntCheck<X> has(IntUnaryOperator property, IntPredicate test, Supplier<X2> exception) throws X2
      Validates a property of the argument. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      exception - the supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the argument is invalid
    • notHas

      public <X2 extends Exception> IntCheck<X> notHas(IntUnaryOperator property, IntPredicate test, Supplier<X2> exception) throws X2
      Validates a property of the argument. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      exception - the supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the argument is invalid
    • has

      public IntCheck<X> has(IntUnaryOperator property, IntRelation test, int object) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the object of the IntRelation
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public IntCheck<X> notHas(IntUnaryOperator property, IntRelation test, int object) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the object of the IntRelation
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public IntCheck<X> has(IntUnaryOperator property, String name, IntRelation test, int object) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      name - The name of the property being tested
      test - the test
      object - the object of the IntRelation
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public IntCheck<X> notHas(IntUnaryOperator property, String name, IntRelation test, int object) throws X
      Validates a property of the argument. While not strictly required, this method is meant to be passed a check from the CommonChecks class and a property extractor function from the CommonProperties class. When providing your own lambdas and/or method references, the error message wil not be very intelligible
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      name - a descriptive name for the property being tested
      test - the test
      object - the object of the IntRelation
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public IntCheck<X> has(IntUnaryOperator property, IntRelation test, int object, String message, Object... msgArgs) throws X
      Validates a property of the argument. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the object of the IntRelation
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • notHas

      public IntCheck<X> notHas(IntUnaryOperator property, IntRelation test, int object, String message, Object... msgArgs) throws X
      Validates a property of the argument. Allows you to provide a custom error message. See the paragraph on Custom Error Messages in the module description for how to specify a custom message.
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the object of the IntRelation
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the property does not pass the test
    • has

      public <X2 extends Exception> IntCheck<X> has(IntUnaryOperator property, IntRelation test, int object, Supplier<X2> exception) throws X2
      Validates a property of the argument. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      X2 - the type of the exception thrown if the property does not pass the test
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the object of the IntRelation
      exception - the supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the property does not pass the test
    • notHas

      public <X2 extends Exception> IntCheck<X> notHas(IntUnaryOperator property, IntRelation test, int object, Supplier<X2> exception) throws X2
      Validates a property of the argument. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      X2 - the type of the exception thrown if the property does not pass the test
      Parameters:
      property - a function that exposes some property of the int value (for example its absolute value or its square root), which is then validated using the specified test
      test - the test
      object - the object of the IntRelation
      exception - the supplier of the exception to be thrown if the argument is invalid
      Returns:
      this instance
      Throws:
      X2 - if the property does not pass the test
    • and

      public IntCheck<X> and(int arg)
      Returns a new IntCheck instance for validating the specified int value. This allows you to chain not just multiple checks for a single argument, but also multiple checks for multiple arguments:
      
       Check.that(list).is(notNull())
        .and(off).is(gte(), 0)
        .and(len).is(gte(), 0)
        .and(off+len).is(lte(), list.size());
       

      The new instance inherits the exception factory of this instance.

      Parameters:
      arg - the value to be validated.
      Returns:
      a new IntCheck instance for validating the specified value
    • and

      public IntCheck<X> and(int arg, String argName)
      Returns a new IntCheck instance for validating the specified value. The new instance inherits the exception factory of this instance.
      Parameters:
      arg - the value to be validated.
      argName - the name of the argument, field or variable being validated
      Returns:
      a new IntCheck instance for validating the specified value
    • and

      public <T> ObjectCheck<T,X> and(T arg)
      Returns a new ObjectCheck instance for validating the specified value. The new instance inherits the exception factory of this instance.
      Type Parameters:
      T - the type of the value to be validated
      Parameters:
      arg - the value to be validated.
      Returns:
      a new IntCheck instance for validating the specified value
    • and

      public <T> ObjectCheck<T,X> and(T arg, String argName)
      Returns a new ObjectCheck instance for validating the specified value. The new instance inherits the exception factory of this instance.
      Type Parameters:
      T - the type of the value to be validated
      Parameters:
      arg - the value to be validated.
      argName - the name of the argument, field or variable being validated
      Returns:
      a new IntCheck instance for validating the specified value