/** * Indicates if it is the last element in collection and goes to the next element * * @return 'true' if current position is last in collection, 'false' otherwise */ public boolean isLastAndNext() { boolean result = isLast(); next(); return result; }
@NotNull public static String addRequestParam (@NotNull String url, @NotNull Pair<String, ?>... properties) { StringBuilder sb = new StringBuilder(url); boolean containsOtherParams = true; if ( !url.contains("?") ) { sb.append("?"); containsOtherParams = false; } boolean isFirst = true; LoopData ld = new LoopData(properties); for (Pair<String, ?> property : properties) { ld.next(); if (!url.contains(property.getFirst())) { if (isFirst && containsOtherParams) { sb.append("&"); isFirst = false; } sb.append(property.getFirst()).append("=").append(property.getSecond()); if (!ld.isLast()) { sb.append("&"); } } } return sb.toString(); } }