Java Assert assertIndex(final int size, final int index)

Here you can find the source of assertIndex(final int size, final int index)

Description

Make sure the index provided as input is inside the range of possible elements of a list.

License

Apache License

Parameter

Parameter Description
size the size of the list
index the index to be checked

Declaration

public static void assertIndex(final int size, final int index) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  w  w  w  .  ja va  2 s.  c  om*/
     * Make sure the index provided as input is inside the range of possible
     * elements of a list.
     * 
     * @param size
     *          the size of the list
     * 
     * @param index
     *          the index to be checked
     */
    public static void assertIndex(final int size, final int index) {
        if (index < 0 || index >= size) {
            throw new ArrayIndexOutOfBoundsException();
        }
    }
}

Related

  1. assertHasLength(String... params)
  2. assertHasText(String str)
  3. assertHexOrDecLongValue(String value)
  4. assertInBounds(final String param, final int value, final int min, final int max)
  5. assertInBounds(int[] coordinates)
  6. assertIndex(final String s, final int index)
  7. assertIndex(int index, String msg)
  8. assertInputNotEmpty(final String input, final String message)
  9. assertInstance(final Object object, final Class c)