SqlUtil { public static String concat(List<String> strings, String separator) { if (strings.isEmpty()) return null; int size = strings.size(); int i = 0; StringBuilder stringBuilder = new StringBuilder(); for (String s : strings) { stringBuilder.append(s); if (i != size - 1) { stringBuilder.append(separator); } i++; } return stringBuilder.toString(); } private  SqlUtil(); static String concat(List<String> strings, String separator); static String getTableName(String opaUnknownPropertyValue); static String concatByAndOperation(List<SqlPredicate> predicates);  }
@Test void shouldConcatenateSetOfStrings() { List<String> strings = List.of("name", "address"); String result = SqlUtil.concat(strings, ", "); assertThat(result, is("name, address")); }
@Test void shouldReturnNullIfListIsEmpty(){ String result = SqlUtil.concat(Collections.emptyList(), ", "); assertThat(result, is(nullValue())); }