io.deephaven.engine.util.IterableUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-table Show documentation
Show all versions of deephaven-engine-table Show documentation
Engine Table: Implementation and closely-coupled utilities
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.engine.util;
import java.util.function.Function;
public class IterableUtils {
public static String makeCommaSeparatedList(Iterable s) {
return appendCommaSeparatedList(new StringBuilder(), s).toString();
}
public static String makeSeparatedList(Iterable s, String separator, Function renderer) {
return appendSeparatedList(new StringBuilder(), s, separator, renderer).toString();
}
public static StringBuilder appendCommaSeparatedList(StringBuilder sb, Iterable s) {
return appendSeparatedList(sb, s, ", ", Object::toString);
}
public static StringBuilder appendSeparatedList(StringBuilder sb, Iterable s, String separator,
Function renderer) {
String currentSep = "";
for (T element : s) {
sb.append(currentSep);
sb.append(renderer.apply(element));
currentSep = separator;
}
return sb;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy