String (int index, int size, @Nullable String desc) { if (index < 0) { return desc + " (" + index + ") must not be negative"; } else if (size < 0) { throw new IllegalArgumentException("negative size: " + size); } else { // index > size return desc + " (" + index + ") must not be greater than size (" + size + ")"; } }