class SeqValidator<T> { private static int iMin = 0; private int iMax = 0; public void assertSeqNotEmpty(T[] seq) throws IllegalArgumentException { if (seq == null) { throw new IllegalArgumentException("seq cannot be null"); } iMax = seq.length - 1; if (iMax < 0) { throw new IllegalArgumentException("seq cannot be empty"); } } public void assertValidRange(T[] seq, int from, int to) throws IllegalArgumentException, IndexOutOfBoundsException { assertSeqNotEmpty(seq); if (from < iMin || from > iMax) { throw new IndexOutOfBoundsException("from is out of bounds"); } if (to < iMin || to > iMax) { throw new IndexOutOfBoundsException("to is out of bounds"); } } }