@Test public void test2DList() { List<String> l = Arrays.asList("123", "456", "789", "1011", "abc", "adf", "efa"); List<List<String>> ll = new ArrayList<>(); for (int i = 0; i < 10; i += 1) { ll.add(l); } System.out.println(displayList(ll, true)); }
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(), "[") + "]"; }
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(), "[") + "]"; } }
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(), "[") + "]"; }  }
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(), "[") + "]"; }  static String display(T v); static String display(T v, boolean useRawDoubleFormat); static String displayDouble(double v, String format); static String displayDouble(double v, String format, boolean useRawDoubleFormat); static String displayDouble(double v); static String displayDouble(double v, boolean useRawDoubleFormat); static String displayList(List<T> list, int numEdgeItems, boolean linebreak); static String displayList(List<T> list, boolean linebreak); static String displayList(List<T> list); static String displayDenseVector(DenseVector dv); static String displayDenseMatrix(DenseMatrix dm); static String displayMap(Map<?, ?> m, int numEdgeItems, boolean linebreak); static String displayMap(Map<?, ?> m); static String displayTable(T[][] table, int nRows, int nCols,
                                          String[] rowNames, String[] colNames, String cornerName,
                                          int nRowEdgeItems, int nColEdgeItems); static String displayTable(T[][] table, int nRows, int nCols,
                                          String[] rowNames, String[] colNames, String cornerName,
                                          int nRowEdgeItems, int nColEdgeItems,
                                          boolean useRawDoubleFormat); static String displayTable(T[][] table, int nRows, int nCols,
                                          String[] rowNames, String[] colNames, String cornerName); static String indentLines(String text, int indentSize); static String prependStringWithIndent(String text, String s); static String displayHeadline(String head, Character padChar); }
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(), "[") + "]"; }  static String display(T v); static String display(T v, boolean useRawDoubleFormat); static String displayDouble(double v, String format); static String displayDouble(double v, String format, boolean useRawDoubleFormat); static String displayDouble(double v); static String displayDouble(double v, boolean useRawDoubleFormat); static String displayList(List<T> list, int numEdgeItems, boolean linebreak); static String displayList(List<T> list, boolean linebreak); static String displayList(List<T> list); static String displayDenseVector(DenseVector dv); static String displayDenseMatrix(DenseMatrix dm); static String displayMap(Map<?, ?> m, int numEdgeItems, boolean linebreak); static String displayMap(Map<?, ?> m); static String displayTable(T[][] table, int nRows, int nCols,
                                          String[] rowNames, String[] colNames, String cornerName,
                                          int nRowEdgeItems, int nColEdgeItems); static String displayTable(T[][] table, int nRows, int nCols,
                                          String[] rowNames, String[] colNames, String cornerName,
                                          int nRowEdgeItems, int nColEdgeItems,
                                          boolean useRawDoubleFormat); static String displayTable(T[][] table, int nRows, int nCols,
                                          String[] rowNames, String[] colNames, String cornerName); static String indentLines(String text, int indentSize); static String prependStringWithIndent(String text, String s); static String displayHeadline(String head, Character padChar);  }