| Modifier and Type | Field and Description |
|---|---|
| public static final BiFunction | |
| public static final BiFunction | |
| public static final BiFunction | SIOOBE_FORMATTER
Utility exception formatters which can be used in |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static < the type of runtime exception to throw if the arguments are
out of bounds X extends RuntimeException> int | Returns: fromIndex if the sub-range within bounds of the rangethe lower-bound (inclusive) of the sub-interval fromIndex, int the size of the sub-range size, int the upper-bound (exclusive) of the range length, BiFunction<String, List<Number>, X> the exception formatter that when applied with this
method name and out-of-bounds arguments returns a runtime
exception. If oobef)null or returns null then, it is as
if an exception formatter produced from an invocation of
outOfBoundsExceptionFormatter(IndexOutOfBounds::new) is used
instead (though it may be more efficient).
Exceptions thrown by the formatter are relayed to the caller.Checks if the sub-range from |
| public static < the type of runtime exception to throw if the arguments are
out of bounds X extends RuntimeException> long | Returns: fromIndex if the sub-range within bounds of the rangethe lower-bound (inclusive) of the sub-interval fromIndex, long the size of the sub-range size, long the upper-bound (exclusive) of the range length, BiFunction<String, List<Number>, X> the exception formatter that when applied with this
method name and out-of-bounds arguments returns a runtime
exception. If oobef)null or returns null then, it is as
if an exception formatter produced from an invocation of
outOfBoundsExceptionFormatter(IndexOutOfBounds::new) is used
instead (though it may be more efficient).
Exceptions thrown by the formatter are relayed to the caller.Checks if the sub-range from |
| public static < the type of runtime exception to throw if the arguments are
out of bounds X extends RuntimeException> int | Returns: fromIndex if the sub-range within bounds of the rangethe lower-bound (inclusive) of the sub-range fromIndex, int the upper-bound (exclusive) of the sub-range toIndex, int the upper-bound (exclusive) the range length, BiFunction<String, List<Number>, X> the exception formatter that when applied with this
method name and out-of-bounds arguments returns a runtime
exception. If oobef)null or returns null then, it is as
if an exception formatter produced from an invocation of
outOfBoundsExceptionFormatter(IndexOutOfBounds::new) is used
instead (though it may be more efficient).
Exceptions thrown by the formatter are relayed to the caller.Checks if the sub-range from |
| public static < the type of runtime exception to throw if the arguments are
out of bounds X extends RuntimeException> long | Returns: fromIndex if the sub-range within bounds of the rangethe lower-bound (inclusive) of the sub-range fromIndex, long the upper-bound (exclusive) of the sub-range toIndex, long the upper-bound (exclusive) the range length, BiFunction<String, List<Number>, X> the exception formatter that when applied with this
method name and out-of-bounds arguments returns a runtime
exception. If oobef)null or returns null then, it is as
if an exception formatter produced from an invocation of
outOfBoundsExceptionFormatter(IndexOutOfBounds::new) is used
instead (though it may be more efficient).
Exceptions thrown by the formatter are relayed to the caller.Checks if the sub-range from |
| public static < the type of runtime exception to throw if the arguments are
out of bounds X extends RuntimeException> int | Returns: index if it is within bounds of the rangethe index index, int the upper-bound (exclusive) of the range length, BiFunction<String, List<Number>, X> the exception formatter that when applied with this
method name and out-of-bounds arguments returns a runtime
exception. If oobef)null or returns null then, it is as
if an exception formatter produced from an invocation of
outOfBoundsExceptionFormatter(IndexOutOfBounds::new) is used
instead (though it may be more efficient).
Exceptions thrown by the formatter are relayed to the caller.Checks if the |
| public static < the type of runtime exception to throw if the arguments are
out of bounds X extends RuntimeException> long | Returns: index if it is within bounds of the rangethe index index, long the upper-bound (exclusive) of the range length, BiFunction<String, List<Number>, X> the exception formatter that when applied with this
method name and out-of-bounds arguments returns a runtime
exception. If oobef)null or returns null then, it is as
if an exception formatter produced from an invocation of
outOfBoundsExceptionFormatter(IndexOutOfBounds::new) is used
instead (though it may be more efficient).
Exceptions thrown by the formatter are relayed to the caller.Checks if the |
| private static RuntimeException | Returns: the runtime exceptionthe exception formatter that when applied with a checkKind
and a list out-of-bounds arguments returns a runtime exception.
If oobef, String null then, it is as if an exception formatter was
supplied that returns IndexOutOfBoundsException for any
given arguments.the kind of bounds check, whose name may correspond
to the name of one of the range check methods, checkIndex,
checkFromToIndex, checkFromIndexSize checkKind, Number... the out-of-bounds arguments that failed the range check.
If the checkKind corresponds to the name of a range check method
then the bounds arguments are those that can be passed in order
to the method. args)Maps out-of-bounds values to a runtime exception. |
| private static RuntimeException | outOfBoundsCheckFromIndexSize(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, int fromIndex, int size, int length)
|
| private static RuntimeException | outOfBoundsCheckFromIndexSize(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, long fromIndex, long size, long length)
|
| private static RuntimeException | outOfBoundsCheckFromToIndex(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, int fromIndex, int toIndex, int length)
|
| private static RuntimeException | outOfBoundsCheckFromToIndex(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, long fromIndex, long toIndex, long length)
|
| private static RuntimeException | outOfBoundsCheckIndex(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, int index, int length)
|
| private static RuntimeException | outOfBoundsCheckIndex(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, long index, long length)
|
| public static < the type of runtime exception to be returned by the given
exception factory and relayed by the exception formatter X extends RuntimeException> BiFunction | Returns: the out-of-bounds exception formatterthe exception factory, that produces an exception from a message
where the message is produced and formatted by the returned
exception formatter. If this factory is stateless and side-effect
free then so is the returned formatter.
Exceptions thrown by the factory are relayed to the caller
of the returned formatter. f)Returns an out-of-bounds exception formatter from an given exception factory. |
| private static String |
| AIOOBE_FORMATTER | back to summary |
|---|---|
| public static final BiFunction<String, List<Number>, ArrayIndexOutOfBoundsException> AIOOBE_FORMATTER | |
| IOOBE_FORMATTER | back to summary |
|---|---|
| public static final BiFunction<String, List<Number>, IndexOutOfBoundsException> IOOBE_FORMATTER | |
| SIOOBE_FORMATTER | back to summary |
|---|---|
| public static final BiFunction<String, List<Number>, StringIndexOutOfBoundsException> SIOOBE_FORMATTER Utility exception formatters which can be used in | |
| Preconditions | back to summary |
|---|---|
| public Preconditions() | |
| checkFromIndexSize | back to summary |
|---|---|
| public static <X extends RuntimeException> int checkFromIndexSize(int fromIndex, int size, int length, BiFunction<String, List<Number>, X> oobef) Checks if the sub-range from The sub-range is defined to be out of bounds if any of the following inequalities is true:
If the sub-range is out of bounds, then a runtime exception is
thrown that is the result of applying the following arguments to the
exception formatter: the name of this method,
| |
| checkFromIndexSize | back to summary |
|---|---|
| public static <X extends RuntimeException> long checkFromIndexSize(long fromIndex, long size, long length, BiFunction<String, List<Number>, X> oobef) Checks if the sub-range from The sub-range is defined to be out of bounds if any of the following inequalities is true:
If the sub-range is out of bounds, then a runtime exception is
thrown that is the result of applying the following arguments to the
exception formatter: the name of this method,
| |
| checkFromToIndex | back to summary |
|---|---|
| public static <X extends RuntimeException> int checkFromToIndex(int fromIndex, int toIndex, int length, BiFunction<String, List<Number>, X> oobef) Checks if the sub-range from The sub-range is defined to be out of bounds if any of the following inequalities is true:
If the sub-range is out of bounds, then a runtime exception is
thrown that is the result of applying the following arguments to the
exception formatter: the name of this method,
| |
| checkFromToIndex | back to summary |
|---|---|
| public static <X extends RuntimeException> long checkFromToIndex(long fromIndex, long toIndex, long length, BiFunction<String, List<Number>, X> oobef) Checks if the sub-range from The sub-range is defined to be out of bounds if any of the following inequalities is true:
If the sub-range is out of bounds, then a runtime exception is
thrown that is the result of applying the following arguments to the
exception formatter: the name of this method,
| |
| checkIndex | back to summary |
|---|---|
| public static <X extends RuntimeException> int checkIndex(int index, int length, BiFunction<String, List<Number>, X> oobef) Checks if the The
If the Implementation Note This method is made intrinsic in optimizing compilers to guide them to perform unsigned comparisons of the index and length when it is known the length is a non-negative value (such as that of an array length or from the upper bound of a loop)
| |
| checkIndex | back to summary |
|---|---|
| public static <X extends RuntimeException> long checkIndex(long index, long length, BiFunction<String, List<Number>, X> oobef) Checks if the The
If the Implementation Note This method is made intrinsic in optimizing compilers to guide them to perform unsigned comparisons of the index and length when it is known the length is a non-negative value (such as that of an array length or from the upper bound of a loop)
| |
| outOfBounds | back to summary |
|---|---|
| private static RuntimeException outOfBounds(BiFunction<String, List<Number>, ? extends RuntimeException> oobef, String checkKind, Number... args) Maps out-of-bounds values to a runtime exception.
| |
| outOfBoundsCheckFromIndexSize | back to summary |
|---|---|
| private static RuntimeException outOfBoundsCheckFromIndexSize(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, int fromIndex, int size, int length) | |
| outOfBoundsCheckFromIndexSize | back to summary |
|---|---|
| private static RuntimeException outOfBoundsCheckFromIndexSize(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, long fromIndex, long size, long length) | |
| outOfBoundsCheckFromToIndex | back to summary |
|---|---|
| private static RuntimeException outOfBoundsCheckFromToIndex(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, int fromIndex, int toIndex, int length) | |
| outOfBoundsCheckFromToIndex | back to summary |
|---|---|
| private static RuntimeException outOfBoundsCheckFromToIndex(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, long fromIndex, long toIndex, long length) | |
| outOfBoundsCheckIndex | back to summary |
|---|---|
| private static RuntimeException outOfBoundsCheckIndex(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, int index, int length) | |
| outOfBoundsCheckIndex | back to summary |
|---|---|
| private static RuntimeException outOfBoundsCheckIndex(BiFunction<String, List<Number>, ? extends RuntimeException> oobe, long index, long length) | |
| outOfBoundsExceptionFormatter | back to summary |
|---|---|
| public static <X extends RuntimeException> BiFunction Returns an out-of-bounds exception formatter from an given exception factory. The exception formatter is a function that formats an out-of-bounds message from its arguments and applies that message to the given exception factory to produce and relay an exception. The exception formatter accepts two arguments: a Three check kinds are supported Formatter arguments conforming to such supported check kinds will
produce specific exception messages describing failed out-of-bounds
checks. Otherwise, more generic exception messages will be produced in
any of the following cases: the check kind is supported but fewer
or more out-of-bounds values are supplied, the check kind is not
supported, the check kind is API Note This method produces an out-of-bounds exception formatter that can be
passed as an argument to any of the supported out-of-bounds range check
methods declared by
The formatter instance AIOOBEF may be passed as an argument to an
out-of-bounds range check method, such as checking if an index
is within the bounds of a limit:
If the bounds check fails then the range check method will throw an
ArrayIndexOutOfBoundsException with an appropriate exception
message that is a produced from AIOOBEF as follows:
| |
| outOfBoundsMessage | back to summary |
|---|---|
| private static String outOfBoundsMessage(String checkKind, List<? extends Number> args) | |