Raises an exception if the specified size exceeds the maximum array size. Should be called whenever an array with a fixed size is created. @param size array capacity @return argument as integer, or 0 if the argument is negative
(final long size)
| 284 | * @return argument as integer, or {@code 0} if the argument is negative |
| 285 | */ |
| 286 | public static int checkCapacity(final long size) { |
| 287 | if(size > MAX_SIZE) throw new ArrayIndexOutOfBoundsException( |
| 288 | "Maximum array size exceeded (" + size + " > " + MAX_SIZE + ")."); |
| 289 | return Math.max(0, (int) size); |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Compares two token arrays for equality. |