
com.azure.cosmos.implementation.query.metrics.TextTable Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.implementation.query.metrics;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
class TextTable {
private static final char CellLeftTop = '┌';
private static final char CellRightTop = '┐';
private static final char CellLeftBottom = '└';
private static final char CellRightBottom = '┘';
private static final char CellHorizontalJointTop = '┬';
private static final char CellHorizontalJointBottom = '┴';
private static final char CellVerticalJointLeft = '├';
private static final char CellTJoint = '┼';
private static final char CellVerticalJointRight = '┤';
private static final char CellHorizontalLine = '-';
private static final char CellVerticalLine = '│';
private List columns;
private String header;
private String topLine;
private String middleLine;
private String bottomLine;
private String rowFormatString;
/**
* Initializes a new instance of the TextTable class.
*
* @param columns The columns of the table
*/
public TextTable(List columns) {
this.columns = new ArrayList<>(columns);
// Building the table header
String headerFormatString = TextTable.buildLineFormatString(columns);
this.header = String.format(headerFormatString, columns.stream().map(textTableColumn -> textTableColumn.columnName).toArray());
// building the different lines
this.topLine = TextTable.buildLine(CellLeftTop, CellRightTop, CellHorizontalJointTop, columns);
this.middleLine = TextTable.buildLine(CellVerticalJointLeft, CellVerticalJointRight, CellTJoint, columns);
this.bottomLine = TextTable.buildLine(CellLeftBottom, CellRightBottom, CellHorizontalJointBottom, columns);
// building the row format string
this.rowFormatString = TextTable.buildLineFormatString(columns);
}
public String getRow(List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy