Class ObjectCheck<T,X extends Exception>

java.lang.Object
org.klojang.check.ObjectCheck<T,X>
Type Parameters:
T - The type of the value to be validated
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 ObjectCheck<T,X extends Exception> extends Object
Facilitates the validation of arbitrarily typed values. See the module summary for a detailed explanation.
  • Method Details

    • ok

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

      public <R, X2 extends Throwable> R ok(FallibleFunction<T,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. For example:
      
       int age = Check.that(person).has(Person::getAge, "age", lt(), 50).ok(Person::getAge);
       
      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 value validated by this instance
      Returns:
      the value computed by the transformation function
      Throws:
      X2 - if the transformation fails
    • then

      public <X2 extends Throwable> void then(FallibleConsumer<T,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 value validated by this instance
      Throws:
      X2 - if the consumer fails while processing the value
    • is

      public ObjectCheck<T,X> is(Predicate<T> test) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be used with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Parameters:
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • isNot

      public ObjectCheck<T,X> isNot(Predicate<T> test) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be used with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Parameters:
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • is

      public ObjectCheck<T,X> is(Predicate<T> 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 argument is invalid
    • isNot

      public ObjectCheck<T,X> isNot(Predicate<T> 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 argument is invalid
    • is

      public <X2 extends Exception> ObjectCheck<T,X> is(Predicate<T> 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 argument is invalid
      Parameters:
      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
    • isNot

      public <X2 extends Exception> ObjectCheck<T,X> isNot(Predicate<T> 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 argument is invalid
      Parameters:
      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
    • is

      public <O> ObjectCheck<T,X> is(Relation<T,O> test, O object) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      O - the type of the value being tested against
      Parameters:
      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 argument is invalid
    • isNot

      public <O> ObjectCheck<T,X> isNot(Relation<T,O> test, O object) throws X
      Validates the argument using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      O - the type of the value being tested against
      Parameters:
      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 argument is invalid
    • is

      public <O> ObjectCheck<T,X> is(Relation<T,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 value being tested against
      Parameters:
      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
    • isNot

      public <O> ObjectCheck<T,X> isNot(Relation<T,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 value being tested against
      Parameters:
      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
    • is

      public <O, X2 extends Exception> ObjectCheck<T,X> is(Relation<T,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 value being tested against
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      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
    • isNot

      public <O, X2 extends Exception> ObjectCheck<T,X> isNot(Relation<T,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 value being tested against
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      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 <P> ObjectCheck<T,X> has(Function<T,P> property, Predicate<P> test) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • notHas

      public <P> ObjectCheck<T,X> notHas(Function<T,P> property, Predicate<P> test) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public <P> ObjectCheck<T,X> has(Function<T,P> property, String name, Predicate<P> test) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 argument is invalid
    • notHas

      public <P> ObjectCheck<T,X> notHas(Function<T,P> property, String name, Predicate<P> test) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      P - the type of the extracted value
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      name - the name of the property being tested
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public <P> ObjectCheck<T,X> has(Function<T,P> property, Predicate<P> test, String message, Object... msgArgs) throws X
      Validates a property of 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:
      P - the type of the extracted value
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • notHas

      public <P> ObjectCheck<T,X> notHas(Function<T,P> property, Predicate<P> test, String message, Object... msgArgs) throws X
      Validates a property of 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:
      P - the type of the extracted value
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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> ObjectCheck<T,X> has(Function<T,P> property, Predicate<P> test, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, using the specified test. 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 transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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> ObjectCheck<T,X> notHas(Function<T,P> property, Predicate<P> test, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, using the specified test. 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 transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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> ObjectCheck<T,X> has(Function<T,P> property, Relation<P,O> test, O object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 argument is invalid
    • notHas

      public <P, O> ObjectCheck<T,X> notHas(Function<T,P> property, Relation<P,O> test, O object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 argument is invalid
    • has

      public <P, O> ObjectCheck<T,X> has(Function<T,P> property, String name, Relation<P,O> test, O object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 argument is invalid
    • notHas

      public <P, O> ObjectCheck<T,X> notHas(Function<T,P> property, String name, Relation<P,O> test, O object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Type Parameters:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public <P, O> ObjectCheck<T,X> has(Function<T,P> property, Relation<P,O> test, O object, String message, Object... msgArgs) throws X
      Validates a property of 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:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
    • notHas

      public <P, O> ObjectCheck<T,X> notHas(Function<T,P> property, Relation<P,O> test, O object, String message, Object... msgArgs) throws X
      Validates a property of 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:
      P - the type of the extracted value
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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> ObjectCheck<T,X> has(Function<T,P> property, Relation<P,O> test, O object, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, using the specified test. 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 transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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> ObjectCheck<T,X> notHas(Function<T,P> property, Relation<P,O> test, O object, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, using the specified test. 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 transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 ObjectCheck<T,X> has(ToIntFunction<T> property, IntPredicate test) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • notHas

      public ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntPredicate test) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public ObjectCheck<T,X> has(ToIntFunction<T> property, String name, IntPredicate test) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      name - the name of the property being tested.
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • notHas

      public ObjectCheck<T,X> notHas(ToIntFunction<T> property, String name, IntPredicate test) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      name - the name of the property being tested.
      test - the test
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public ObjectCheck<T,X> has(ToIntFunction<T> property, IntPredicate test, String message, Object... msgArgs) throws X
      Validates a property of 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:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • notHas

      public ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntPredicate test, String message, Object... msgArgs) throws X
      Validates a property of 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:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      test - the test
      message - the message pattern
      msgArgs - the message arguments
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public <X2 extends Exception> ObjectCheck<T,X> has(ToIntFunction<T> property, IntPredicate test, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, 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 argument is invalid
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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> ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntPredicate test, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, 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 argument is invalid
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 <O> ObjectCheck<T,X> has(ToIntFunction<T> property, IntObjRelation<O> test, O object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 argument is invalid
    • notHas

      public <O> ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntObjRelation<O> test, O object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 argument is invalid
    • has

      public <O> ObjectCheck<T,X> has(ToIntFunction<T> property, String name, IntObjRelation<O> test, O object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • notHas

      public <O> ObjectCheck<T,X> notHas(ToIntFunction<T> property, String name, IntObjRelation<O> test, O object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public <O> ObjectCheck<T,X> has(ToIntFunction<T> property, 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.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
    • notHas

      public <O> ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntObjRelation<O> test, O object, String message, Object... msgArgs) throws X
      Validates a property of 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.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      O - the type of the value being tested against
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 <O, X2 extends Exception> ObjectCheck<T,X> has(ToIntFunction<T> property, IntObjRelation<O> test, O object, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, using the specified test. Allows you to throw a different type of exception for this particular test.
      Type Parameters:
      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 transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 <O, X2 extends Exception> ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntObjRelation<O> test, O object, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, using the specified test. Allows you to throw a different type of exception for this particular test.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      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 transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 ObjectCheck<T,X> has(ToIntFunction<T> property, IntRelation test, int object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 argument is invalid
    • notHas

      public ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntRelation test, int object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class and a "property" from the CommonProperties class so that an informative error message is generated if the argument turns out to be invalid.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 argument is invalid
    • has

      public ObjectCheck<T,X> has(ToIntFunction<T> property, String name, IntRelation test, int object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • notHas

      public ObjectCheck<T,X> notHas(ToIntFunction<T> property, String name, IntRelation test, int object) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. While not strictly required, this method is meant to be used in combination with a check from the CommonChecks class so that an informative error message is generated if the argument turns out to be invalid.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
      object - the value that the argument is tested against (called "the object" of a relation)
      Returns:
      this instance
      Throws:
      X - if the argument is invalid
    • has

      public ObjectCheck<T,X> has(ToIntFunction<T> property, IntRelation test, int object, String message, Object... msgArgs) throws X
      Validates a property of the argument, retrieved through the specified function, using the specified test. Allows you to provide a custom error message. See the package description for how to specify a custom error message.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
    • notHas

      public ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntRelation test, int object, String message, Object... msgArgs) throws X
      Validates a property of 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.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 <X2 extends Exception> ObjectCheck<T,X> has(ToIntFunction<T> property, IntRelation test, int object, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, using the specified test. Allows you to throw a different type of exception for this particular test.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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 <X2 extends Exception> ObjectCheck<T,X> notHas(ToIntFunction<T> property, IntRelation test, int object, Supplier<X2> exception) throws X2
      Validates a property of the argument, retrieved through the specified function, using the specified test. Allows you to throw a different type of exception for this particular test.

      Note that this method is heavily overloaded. Therefore you need to pay attention when providing a lambda or method reference for both the property argument and the test argument. Plain lambdas or method references may cause the compiler to complain about an Ambiguous method call. If so, see the package description for what you need to do.

      Type Parameters:
      X2 - the type of the exception thrown if the argument is invalid
      Parameters:
      property - a function that transforms the value validated by this ObjectCheck into another value, which is to be validated using the specified test. This would typically be a function that extracts a bean property from a JavaBean
      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
    • and

      public IntCheck<X> and(int arg)
      Returns an IntCheck instance for validating the specified value. 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 an 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 <U> ObjectCheck<U,X> and(U arg)
      Returns a new ObjectCheck instance for validating the specified value; supposedly another value than the one validated by this instance. The new instance inherits the exception factory of this instance.
      Type Parameters:
      U - the type of the value
      Parameters:
      arg - the value to be validated.
      Returns:
      a new ObjectCheck instance for validating the specified value
    • and

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