class PrettyDisplayUtils {

    public static <T> String displayList(List<T> list, int numEdgeItems, boolean linebreak) {
        StringBuilder sbd = new StringBuilder();
        String delimiter = linebreak ? ",\n" : ", ";
        if (list.size() <= 2 * numEdgeItems) {
            for (int i = 0; i < list.size(); i += 1) {
                sbd.append(display(list.get(i)));
                if (i < list.size() - 1) {
                    sbd.append(delimiter);
                }
            }
        } else {
            for (int i = 0; i < numEdgeItems; i += 1) {
                sbd.append(display(list.get(i)));
                sbd.append(delimiter);
            }
            sbd.append("...");
            sbd.append(delimiter);
            for (int i = list.size() - numEdgeItems; i < list.size(); i += 1) {
                sbd.append(display(list.get(i)));
                if (i < list.size() - 1) {
                    sbd.append(delimiter);
                }
            }
        }
        return prependStringWithIndent(sbd.toString(), "[") + "]";
    }

}