SelectQuery { Object[] fetchParams(List<Object> params, Integer skip, Integer limit) { if (skip != null && limit == null) throw new Error("limit must not be null if skip is not, skip=" + skip); if (skip == null && limit == null) return params.toArray(); Integer skipValue = skip == null ? Integer.valueOf(0) : skip; if (params.isEmpty()) return new Object[]{skipValue, limit}; int length = params.size(); Object[] results = params.toArray(new Object[params.size() + 2]); results[length] = skipValue; results[length + 1] = limit; return results; } SelectQuery(Class<T> entityClass);   }
@Test void fetchParams() { Object[] params = selectQuery.fetchParams(List.of("value"), null, 100); assertThat(params).containsExactly("value", 0, 100); }