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)
Facilitates the validation of
int
values. See the
module summary for a detailed
explanation.-
Method Summary
Modifier and TypeMethodDescriptionand
(int arg) Returns a newIntCheck
instance for validating the specifiedint
value.Returns a newIntCheck
instance for validating the specified value.<T> ObjectCheck
<T, X> and
(T arg) Returns a newObjectCheck
instance for validating the specified value.<T> ObjectCheck
<T, X> Returns a newObjectCheck
instance for validating the specified value.has
(IntFunction<P> property, String name, Predicate<P> test) Validates a property of the argument.has
(IntFunction<P> property, String name, Relation<P, O> test, O object) Validates a property of the argument.has
(IntFunction<P> property, Predicate<P> test) Validates a property of the argument.has
(IntFunction<P> property, Predicate<P> test, String message, Object... msgArgs) Validates a property of the argument.has
(IntFunction<P> property, Predicate<P> test, Supplier<X2> exception) Validates a property of the argument.has
(IntFunction<P> property, Relation<P, O> test, O object) Validates a property of the argument.has
(IntFunction<P> property, Relation<P, O> test, O object, String message, Object... msgArgs) Validates a property of the argument.has
(IntFunction<P> property, Relation<P, O> test, O object, Supplier<X2> exception) Validates a property of the argument.has
(IntUnaryOperator property, String name, IntPredicate test) Validates a property of the argument.has
(IntUnaryOperator property, String name, IntRelation test, int object) Validates a property of the argument.has
(IntUnaryOperator property, IntPredicate test) Validates a property of the argument.has
(IntUnaryOperator property, IntPredicate test, String message, Object... msgArgs) Validates a property of the argument.has
(IntUnaryOperator property, IntPredicate test, Supplier<X2> exception) Validates a property of the argument.has
(IntUnaryOperator property, IntRelation test, int object) Validates a property of the argument.has
(IntUnaryOperator property, IntRelation test, int object, String message, Object... msgArgs) Validates a property of the argument.has
(IntUnaryOperator property, IntRelation test, int object, Supplier<X2> exception) Validates a property of the argument.is
(IntPredicate test) Validates the argument using the specified test.is
(IntPredicate test, String message, Object... msgArgs) Validates the argument using the specified test.is
(IntPredicate test, Supplier<X2> exception) Validates the argument using the specified test.is
(IntObjRelation<O> test, O object) Validates the argument using the specified test.is
(IntObjRelation<O> test, O object, String message, Object... msgArgs) Validates the argument using the specified test.is
(IntObjRelation<O> test, O object, Supplier<X2> exception) Validates the argument using the specified test.is
(IntRelation test, int object) Validates the argument using the specified test.is
(IntRelation test, int object, String message, Object... msgArgs) Validates the argument using the specified test.is
(IntRelation test, int object, Supplier<X2> exception) Validates the argument using the specified test.isNot
(IntPredicate test) Validates the argument using the specified test.isNot
(IntPredicate test, String message, Object... msgArgs) Validates the argument using the specified test.isNot
(IntPredicate test, Supplier<X2> exception) Validates the argument using the specified test.isNot
(IntObjRelation<O> test, O object) Validates the argument using the specified test.isNot
(IntObjRelation<O> test, O object, String message, Object... msgArgs) Validates the argument using the specified test.isNot
(IntObjRelation<O> test, O object, Supplier<X2> exception) Validates the argument using the specified test.isNot
(IntRelation test, int object) Validates the argument using the specified test.isNot
(IntRelation test, int object, String message, Object... msgArgs) Validates the argument using the specified test.isNot
(IntRelation test, int object, Supplier<X2> exception) Validates the argument using the specified test.<R,
X2 extends Throwable>
RmapToObj
(FallibleIntFunction<R, X2> transformer) Passes the validated value to the specified function and returns the value it computes.notHas
(IntFunction<P> property, String name, Predicate<P> test) Validates a property of the argument.notHas
(IntFunction<P> property, String name, Relation<P, O> test, O object) Validates a property of the argument.notHas
(IntFunction<P> property, Predicate<P> test) Validates a property of the argument.notHas
(IntFunction<P> property, Predicate<P> test, String message, Object... msgArgs) Validates a property of the argument.notHas
(IntFunction<P> property, Predicate<P> test, Supplier<X2> exception) Validates a property of the argument.notHas
(IntFunction<P> property, Relation<P, O> test, O object) Validates a property of the argument.notHas
(IntFunction<P> property, Relation<P, O> test, O object, String message, Object... msgArgs) Validates a property of the argument.notHas
(IntFunction<P> property, Relation<P, O> test, O object, Supplier<X2> exception) Validates a property of the argument.notHas
(IntUnaryOperator property, String name, IntPredicate test) Validates a property of the argument.notHas
(IntUnaryOperator property, String name, IntRelation test, int object) Validates a property of the argument.notHas
(IntUnaryOperator property, IntPredicate test) Validates a property of the argument.notHas
(IntUnaryOperator property, IntPredicate test, String message, Object... msgArgs) Validates a property of the argument.notHas
(IntUnaryOperator property, IntPredicate test, Supplier<X2> exception) Validates a property of the argument.notHas
(IntUnaryOperator property, IntRelation test, int object) Validates a property of the argument.notHas
(IntUnaryOperator property, IntRelation test, int object, String message, Object... msgArgs) Validates a property of the argument.notHas
(IntUnaryOperator property, IntRelation test, int object, Supplier<X2> exception) Validates a property of the argument.int
ok()
Returns theint
value validated by this instance.<X2 extends Throwable>
intok
(FallibleIntUnaryOperator<X2> transformer) Passes the validated value to the specified function and returns the value it computes.<X2 extends Throwable>
voidthen
(FallibleIntConsumer<X2> consumer) Passes the validated value to a consumer for further processing.
-
Method Details
-
ok
public int ok()Returns theint
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
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 theint
value validated by this instance- Returns:
- the value computed by the transformation function
- Throws:
X2
- if the transformation fails
-
mapToObj
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 valueX2
- the type of the exception thrown if the transformation fails- Parameters:
transformer
- a function that transforms theint
value validated by this instance- Returns:
- the value computed by the
Function
- Throws:
X2
- if the transformation fails
-
then
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 theint
value validated by this instance- Throws:
X2
- if the consumer fails while processing the value
-
is
Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from theCommonChecks
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 theint
value does not pass the test
-
isNot
Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from theCommonChecks
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 theint
value does not pass the test
-
is
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 testmessage
- the message patternmsgArgs
- the message arguments- Returns:
- this instance
- Throws:
X
- if theint
value does not pass the test
-
isNot
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 testmessage
- the message patternmsgArgs
- the message arguments- Returns:
- this instance
- Throws:
X
- if theint
value does not pass the test
-
is
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 theint
value does not pass the test- Parameters:
test
- the testexception
- the supplier of the exception to be thrown if the argument is invalid TheSupplier
of the exception to be thrown if the argument is invalid- Returns:
- this instance
- Throws:
X2
- if theint
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 theint
value does not pass the test- Parameters:
test
- the testexception
- the supplier of the exception to be thrown if the argument is invalid TheSupplier
of the exception to be thrown if the argument is invalid- Returns:
- this instance
- Throws:
X2
- if theint
value does not pass the test
-
is
Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from theCommonChecks
class. When providing your own lambda or method reference, the error message wil not be very intelligible.- Parameters:
test
- the testobject
- the object of theRelation
- Returns:
- this instance
- Throws:
X
- if theint
value does not pass the test
-
isNot
Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from theCommonChecks
class. When providing your own lambda or method reference, the error message wil not be very intelligible.- Parameters:
test
- the testobject
- the object of theRelation
- Returns:
- this instance
- Throws:
X
- if theint
value does not pass the test
-
is
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 testobject
- the object of theIntObjRelation
message
- the message patternmsgArgs
- the message arguments- Returns:
- this instance
- Throws:
X
- if theint
value does not pass the test
-
isNot
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 testobject
- the object of theIntObjRelation
message
- the message patternmsgArgs
- the message arguments- Returns:
- this instance
- Throws:
X
- if theint
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 theint
value does not pass the test- Parameters:
test
- the testobject
- the object of theIntObjRelation
exception
- the supplier of the exception to be thrown if the argument is invalid TheSupplier
of the exception to be thrown if the argument is invalid- Returns:
- this instance
- Throws:
X2
- if theint
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 theint
value does not pass the test- Parameters:
test
- the testobject
- the object of theIntObjRelation
exception
- the supplier of the exception to be thrown if the argument is invalid TheSupplier
of the exception to be thrown if the argument is invalid- Returns:
- this instance
- Throws:
X2
- if theint
value does not pass the test
-
is
Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from theCommonChecks
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 theIntObjRelation
- Parameters:
test
- the testobject
- the object of theIntObjRelation
- Returns:
- this instance
- Throws:
X
- if theint
value does not pass the test
-
isNot
Validates the argument using the specified test. While not strictly required, this method is meant to be passed a check from theCommonChecks
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 theIntObjRelation
- Parameters:
test
- the testobject
- the object of theIntObjRelation
- Returns:
- this instance
- Throws:
X
- if theint
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 theIntObjRelation
- Parameters:
test
- the testobject
- the object of theIntObjRelation
message
- the message patternmsgArgs
- the message arguments- Returns:
- this instance
- Throws:
X
- if theint
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 theIntObjRelation
- Parameters:
test
- the testobject
- the object of theIntObjRelation
message
- the message patternmsgArgs
- the message arguments- Returns:
- this instance
- Throws:
X
- if theint
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 theIntObjRelation
X2
- the type of exception thrown if theint
value does not pass the test- Parameters:
test
- the testobject
- the object of theIntObjRelation
exception
- the supplier of the exception to be thrown if the argument is invalid TheSupplier
of the exception to be thrown if the argument is invalid- Returns:
- this instance
- Throws:
X2
- if theint
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 theIntObjRelation
X2
- the type of exception thrown if theint
value does not pass the test- Parameters:
test
- the testobject
- the object of theIntObjRelation
exception
- the supplier of the exception to be thrown if the argument is invalid TheSupplier
of the exception to be thrown if the argument is invalid- Returns:
- this instance
- Throws:
X2
- if theint
value does not pass the test
-
has
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the test- Returns:
- this instance
- Throws:
X
- if the property does not pass the test
-
notHas
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the test- Returns:
- this instance
- Throws:
X
- if the property does not pass the test
-
has
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testname
- The name of the property being tested.test
- the test- Returns:
- this instance
- Throws:
X
- if the property does not pass the test
-
notHas
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testname
- 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testmessage
- the message patternmsgArgs
- 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testmessage
- the message patternmsgArgs
- 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 valueX2
- the type of the exception thrown if the argument is invalid- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testexception
- 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 valueX2
- the type of the exception thrown if the argument is invalid- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testexception
- the supplier of the exception to be thrown if the argument is invalid- Returns:
- this instance
- Throws:
X2
- if the argument is invalid
-
has
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 valueO
- the type of the value being tested against- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- 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
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 valueO
- the type of the value being tested against- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- 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 XValidates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 valueO
- the type of the value being tested against- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testname
- The name of the property being tested.test
- the testobject
- 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 XValidates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 valueO
- the type of the value being tested against- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testname
- The name of the property being tested.test
- the testobject
- 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 XValidates 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 valueO
- the type of the value being tested against- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- the value that the argument is tested against (called "the object" of a relation)message
- the message patternmsgArgs
- 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 XValidates 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 valueO
- the type of the value being tested against- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- the value that the argument is tested against (called "the object" of a relation)message
- the message patternmsgArgs
- the message arguments- Returns:
- this instance
- Throws:
X
- if the argument is invalid
-
has
public <P,O, IntCheck<X> hasX2 extends Exception> (IntFunction<P> property, Relation<P, O> test, O object, Supplier<X2> exception) throws X2Validates 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 valueO
- the type of the value being tested againstX2
- the type of the exception thrown if the argument is invalid- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- 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, IntCheck<X> notHasX2 extends Exception> (IntFunction<P> property, Relation<P, O> test, O object, Supplier<X2> exception) throws X2Validates 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 valueO
- the type of the value being tested againstX2
- the type of the exception thrown if the argument is invalid- Parameters:
property
- a function that exposes some property of theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- 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
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the test- Returns:
- this instance
- Throws:
X
- if the property does not pass the test
-
notHas
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the test- Returns:
- this instance
- Throws:
X
- if the property does not pass the test
-
has
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testname
- The name of the property being tested. In error messages the fully-qualified name will be used and constructed usingargName + "." + name
.test
- the test- Returns:
- this instance
- Throws:
X
- if the property does not pass the test
-
notHas
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testname
- The name of the property being tested. In error messages the fully-qualified name will be used and constructed usingargName + "." + 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testmessage
- the message patternmsgArgs
- 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testmessage
- the message patternmsgArgs
- 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testexception
- 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testexception
- the supplier of the exception to be thrown if the argument is invalid- Returns:
- this instance
- Throws:
X2
- if the argument is invalid
-
has
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- the object of theIntRelation
- Returns:
- this instance
- Throws:
X
- if the property does not pass the test
-
notHas
Validates a property of the argument. While not strictly required, this method is meant to be passed a check from theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- the object of theIntRelation
- 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 theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testname
- The name of the property being testedtest
- the testobject
- the object of theIntRelation
- 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 theCommonChecks
class and a property extractor function from theCommonProperties
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testname
- a descriptive name for the property being testedtest
- the testobject
- the object of theIntRelation
- 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- the object of theIntRelation
message
- the message patternmsgArgs
- 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- the object of theIntRelation
message
- the message patternmsgArgs
- 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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- the object of theIntRelation
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 theint
value (for example its absolute value or its square root), which is then validated using the specified testtest
- the testobject
- the object of theIntRelation
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
Returns a newIntCheck
instance for validating the specifiedint
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
Returns a newIntCheck
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
Returns a newObjectCheck
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
Returns a newObjectCheck
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
-