@GwtCompatible public final class PrimitiveArrayCheck extends ObjectBaseCheck<Object,PrimitiveArrayCheck>
arg, nullAllowed
Constructor and Description |
---|
PrimitiveArrayCheck(Object arg,
int argLength)
For internal use only.
|
Modifier and Type | Method and Description |
---|---|
PrimitiveArrayCheck |
hasLength(int length)
Checks that the array argument has the given length, throwing an
exception otherwise.
|
PrimitiveArrayCheck |
hasLengthBetween(int min,
int max)
Checks that the array argument's length is between the two given numbers,
throwing an exception otherwise.
|
IntCheck |
hasLengthWhich()
Creates an
IntCheck property check for the length of the array
argument. |
PrimitiveArrayCheck |
isNotEmpty()
Checks that the array argument is not empty (meaning it has a length
greater than zero), throwing an exception otherwise.
|
check, checkNull, checkWithCause, hasClass, intPropertyCheck, isEqualTo, isInstanceOf, isNotNull, isNullOr, isSameAs, objectPropertyCheck
checkConversion, me, named, not
public PrimitiveArrayCheck(Object arg, int argLength)
public PrimitiveArrayCheck isNotEmpty()
The message type used for exceptions thrown by this method is
MessageType.ARG_EMPTY
.
IllegalArgumentException
- if the array argument is emptypublic PrimitiveArrayCheck hasLength(int length)
The message type used for exceptions thrown by this method is
MessageType.ARG_LENGTH
.
To create more sophisticated checks using the array length, use the
hasLengthWhich()
property check.
length
- The length the array should haveIllegalArgumentException
- if the array argument has a length different from the given
one.hasLengthBetween(int, int)
public PrimitiveArrayCheck hasLengthBetween(int min, int max)
The message type used for exceptions thrown by this method is
MessageType.ARG_LENGTH_BETWEEN
.
To create more sophisticated checks using the array length, use the
hasLengthWhich()
property check.
min
- The minimum length of the arraymax
- The maximum lengthIllegalArgumentException
- If the length of the array is strictly less than
min
or strictly greater than max
.public IntCheck hasLengthWhich()
IntCheck
property check for the length of the array
argument. It can be used to create advanced checks using the array
length. For example:
Check.that(array).isNullOr().hasLengthWhich().isGreaterThan(3);
Just like a check method, this method first asserts the non-nullness of the argument, throwing an exception in case of a failure.
The returned check has the length of this check's array set as the
argument and an argument name that indicates this fact. If the array is
null
and allowed to be so (like in the above example), the
returned property check is completely disabled, meaning none of its check
methods will throw an exception. An inversion called before this method
is ignored and does not have any effect on the check
methods called on the returned property check.
Copyright © 2012–2017 Michael Faes. All rights reserved.