code: public static int checkElementIndex(
          int index,
          int size,
          final Eid eid,
          final String messageFormat,
          final Object... parameters
      ) {
          if (isSizeIllegal(size)) {
              throw new EidIllegalArgumentException(
                  ensureEid(eid).message(messageFormat, parameters)
              );
          }
          if (isIndexAndSizeIllegal(index, size)) {
              throw new EidIndexOutOfBoundsException(
                  ensureEid(eid).message(messageFormat, parameters)
              );
          }
          return index;
      }
docs: Ensures that {@code index} specifies a valid <i>element</i> in an array,
  list or string of size {@code size}. An element
  index may range from zero, inclusive, to {@code size}, exclusive.
  
  @param index         a user-supplied index identifying an element of an
  array, list or string
  @param size          the size of that array, list or string
  @param eid           the text to use to describe this index in an error
  message
  @param messageFormat message format in form accepted by
  {@link MessageFormat#format(String, Object...)}
  @param parameters    parameters fo message format in accepted by
  {@link MessageFormat#format(String, Object...)}
  @return the value of {@code index}
  @throws EidIndexOutOfBoundsException if {@code index} is negative or is
  not less than {@code size}
  @throws EidIllegalArgumentException  if {@code size} is negative