@GwtCompatible public final class LongCheck extends PrimitiveBaseCheck<LongCheck>
long
arguments.
It provides methods like isPositive()
, isGreaterThan(long)
or isBetween(long, long)
.
Constructor and Description |
---|
LongCheck(long arg)
For internal use only.
|
Modifier and Type | Method and Description |
---|---|
LongCheck |
is(long number)
Checks that the
long argument is equal to the given number,
throwing an exception otherwise. |
LongCheck |
isBetween(long min,
long max)
Checks that the
long argument is greater than or equal to
min and less than or equal to max , throwing an
exception otherwise. |
LongCheck |
isGreaterThan(long number)
Checks that the
long argument is (strictly) greater than the
given number, throwing an exception otherwise. |
LongCheck |
isLessThan(long number)
Checks that the
long argument is (strictly) less than the
given number, throwing an exception otherwise. |
LongCheck |
isNegative()
Checks that the
long argument is negative, throwing an
exception otherwise. |
LongCheck |
isPositive()
Checks that the
long argument is positive, throwing an
exception otherwise. |
check, disable
checkConversion, me, named, not
public LongCheck isPositive()
long
argument is positive, throwing an
exception otherwise. Note that zero is not a valid number. Often, you
want to check that a number is non-negative. Use the inverted
isNegative()
check for that:
Check.that(number).not().isNegative();
The message type used for exceptions thrown by this method is
MessageType.ARG_POSITIVE
.
IllegalArgumentException
- if argument is not positiveisNegative()
public LongCheck isNegative()
long
argument is negative, throwing an
exception otherwise.
The message type used for exceptions thrown by this method is
MessageType.ARG_NEGATIVE
.
IllegalArgumentException
- if argument is not negativeisPositive()
public LongCheck is(long number)
long
argument is equal to the given number,
throwing an exception otherwise. This check exists merely for reasons of
symmetry to the IntCheck
class which can be used as a property
check. See StringCheck.hasLengthWhich()
for example. However, in
conjunction with inversion (see BaseCheck.not()
), this method can also be
used to exclude a single value.
The message type used for exceptions thrown by this method is
MessageType.ARG_IS
.
number
- The number this argument must be equal toIllegalArgumentException
- if argument is not equal to the given numberpublic LongCheck isGreaterThan(long number)
long
argument is (strictly) greater than the
given number, throwing an exception otherwise. To create a
greater-than-or-equals check, you may either decrement the
number
argument by one or use an inverted
isLessThan(long)
check:
Check.that(number).not().isLessThan(1L);
The message type used for exceptions thrown by this method is
MessageType.ARG_GREATER
.
number
- The number this argument must be greater thanIllegalArgumentException
- if argument is not greater than the given numberpublic LongCheck isLessThan(long number)
long
argument is (strictly) less than the
given number, throwing an exception otherwise. To create a
less-than-or-equals check, you may either increment the
number
argument by one or use an inverted
isGreaterThan(long)
check:
Check.that(number).not().isGreaterThan(1L);
The message type used for exceptions thrown by this method is
MessageType.ARG_LESS
.
number
- The number this argument must be less thanIllegalArgumentException
- if argument is not less than the given numberpublic LongCheck isBetween(long min, long max)
long
argument is greater than or equal to
min
and less than or equal to max
, throwing an
exception otherwise.
To create a strict or one-sided-strict between test, you may either
increment or decrement the arguments of this check or use the
isGreaterThan(long)
and isLessThan(long)
checks,
possibly in conjunction with BaseCheck.not()
.
The message type used for exceptions thrown by this method is
MessageType.ARG_BETWEEN
.
min
- The minimum numbermax
- The maximum numberIllegalArgumentException
- if argument is not between the two given numbers as defined
aboveCopyright © 2012–2017 Michael Faes. All rights reserved.