Source:
<code>private void printSubscriptions(List<SubscriptionListEntry> entries) { PrintStream console = System.out; int[] columnWidth = new int[4]; <START> columnWidth[0] = entries.stream().mapToInt(s -> s.id.length()).max().orElse(-1); <END> columnWidth[1] = entries.stream().mapToInt(s -> s.callbackUrl.length()).max().orElse(-1); columnWidth[2] = entries.stream().mapToInt(s -> s.isEnterprise.length()).max().orElse(-1); columnWidth[3] = entries.stream().mapToInt(s -> s.sourceIds.length()).max().orElse(-1); columnWidth[0] = Math.max(columnWidth[0], SUBSCRIPTION_ID_COLUMN_HEADER.length()); columnWidth[1] = Math.max(columnWidth[1], CALLBACK_COLUMN_HEADER.length()); columnWidth[2] = Math.max(columnWidth[2], ENTERPRISE_COLUMN_HEADER.length()); columnWidth[3] = Math.max(columnWidth[3], SOURCE_ID_COLUMN_HEADER.length()); String rowFormatString = String.format( "%%-%ds | %%-%ds | %%-%ds | %%-%ds", columnWidth[0], columnWidth[1], columnWidth[2], columnWidth[3]); console.println(); console.print("Total subscriptions found: " + entries.size()); console.println(); console.println(); console.print(CYAN_CONSOLE_COLOR); console.printf( rowFormatString, SUBSCRIPTION_ID_COLUMN_HEADER, CALLBACK_COLUMN_HEADER, ENTERPRISE_COLUMN_HEADER, SOURCE_ID_COLUMN_HEADER); console.println(DEFAULT_CONSOLE_COLOR); for (SubscriptionListEntry entry : entries) { String rowColor = (entry.ping()) ? DEFAULT_CONSOLE_COLOR : RED_CONSOLE_COLOR; console.print(rowColor); console.printf( rowFormatString, entry.id, entry.callbackUrl, entry.isEnterprise, entry.sourceIds); console.println(DEFAULT_CONSOLE_COLOR); } }</code><technical_language>A loop more efficient separate reduce operations</technical_language>

Target:
private void printSubscriptions(List<SubscriptionListEntry> entries) { PrintStream console = System.out; int[] columnWidth = new int[] { SUBSCRIPTION_ID_COLUMN_HEADER.length(), CALLBACK_COLUMN_HEADER.length(), ENTERPRISE_COLUMN_HEADER.length(), SOURCE_ID_COLUMN_HEADER.length() }; for (SubscriptionListEntry entry : entries) { int column0Width = entry.id.length(); int column1Width = entry.callbackUrl.length(); int column2Width = entry.isEnterprise.length(); int column3Width = entry.sourceIds.length(); if (column0Width > columnWidth[0]) columnWidth[0] = column0Width; if (column1Width > columnWidth[1]) columnWidth[1] = column1Width; if (column2Width > columnWidth[2]) columnWidth[2] = column2Width; if (column3Width > columnWidth[3]) columnWidth[3] = column3Width; } String rowFormatString = String.format( "%%-%ds | %%-%ds | %%-%ds | %%-%ds", columnWidth[0], columnWidth[1], columnWidth[2], columnWidth[3]); console.println(); console.print("Total subscriptions found: " + entries.size()); console.println(); console.println(); console.print(CYAN_CONSOLE_COLOR); console.printf( rowFormatString, SUBSCRIPTION_ID_COLUMN_HEADER, CALLBACK_COLUMN_HEADER, ENTERPRISE_COLUMN_HEADER, SOURCE_ID_COLUMN_HEADER); console.println(DEFAULT_CONSOLE_COLOR); for (SubscriptionListEntry entry : entries) { String rowColor = (entry.ping()) ? DEFAULT_CONSOLE_COLOR : RED_CONSOLE_COLOR; console.print(rowColor); console.printf( rowFormatString, entry.id, entry.callbackUrl, entry.isEnterprise, entry.sourceIds); console.println(DEFAULT_CONSOLE_COLOR); } }