validIndex static method
Validates that the index is within the bounds of the argument iterable; otherwise throwing an exception with the specified message.
Validate.validIndex(iterable, 2, "The validated array index is invalid");
If the array is [null], then the message of the exception is "The validated object is null".
iterable
the iterable to check, validated not null by this method
index
the index to check
message
the exception message if invalid, not null
Returns the validated iterable (never null
for method chaining)
Throws ArgumentError if the array is null
Throws RangeError if the index is invalid
Implementation
static Iterable validIndex(Iterable iterable, int index,
[String message = DEFAULT_VALID_INDEX_ARRAY_EX_MESSAGE]) {
GValidate.notNull(iterable);
if (index < 0 || index >= iterable.length) {
throw new RangeError(message);
}
return iterable;
}