本文整理汇总了Java中org.springframework.shell.support.table.Table类的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于org.springframework.shell.support.table包,在下文中一共展示了Table类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: issuebranches
import org.springframework.shell.support.table.Table; //导入依赖的package包/类
/**
* List the branches with their tickets of the git repository.
*
* @param projectName
* @return
* @throws Exception
*/
@CliCommand("git issuebranches")
public Table issuebranches(@CliOption(key = { "" }, mandatory = true) String projectName,
@CliOption(key = "resolved", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") Boolean resolved)
throws Exception {
Project project = ReleaseTrains.getProjectByName(projectName);
TicketBranches ticketBranches = git.listTicketBranches(project);
Table table = new Table();
table.addHeader(1, new TableHeader("Branch"));
table.addHeader(2, new TableHeader("Status"));
table.addHeader(3, new TableHeader("Description"));
ticketBranches.stream().sorted().//
filter(branch -> ticketBranches.hasTicketFor(branch, resolved)).//
forEachOrdered(branch -> {
Optional<Ticket> ticket = ticketBranches.findTicket(branch);
table.addRow(branch.toString(), //
ticket.map(t -> t.getTicketStatus().getLabel()).orElse(""), //
ticket.map(t -> t.getSummary()).orElse(""));
});
return table;
}
示例2: renderMultiValueMap
import org.springframework.shell.support.table.Table; //导入依赖的package包/类
/**
* Renders a 2 columns wide table with the given headers and rows. If headers are provided it should match with the
* number of columns.
*
* @param rows rows of the table, each value will be added as a new row with the same key
* @param headers headers of the table
* @return formatted table
*/
public static String renderMultiValueMap(Map<String, List<String>> rows, String... headers) {
Table table = createTable(headers);
if (rows != null) {
for (String key : rows.keySet()) {
List<String> values = rows.get(key);
if (values != null) {
for (String value : values) {
table.addRow(key, value);
}
}
}
}
return format(table);
}
示例3: renderMapValueMap
import org.springframework.shell.support.table.Table; //导入依赖的package包/类
/**
* Renders a 3 columns wide table with the given headers and rows. If headers are provided it should match with the
* number of columns.
*
* @param rows rows of the table, value map will be added as the last 2 columns to the table
* @param headers headers of the table
* @return formatted table
*/
public static String renderMapValueMap(Map<String, Map<String, String>> rows, String... headers) {
Table table = createTable(headers);
if (rows != null) {
for (String key1 : rows.keySet()) {
Map<String, String> values = rows.get(key1);
if (values != null) {
for (String key2 : values.keySet()) {
table.addRow(key1, key2, values.get(key2));
}
}
}
}
return format(table);
}
示例4: createTable
import org.springframework.shell.support.table.Table; //导入依赖的package包/类
private static Table createTable(String... headers) {
Table table = new Table();
if (headers != null) {
int column = 1;
for (String header : headers) {
table.addHeader(column++, new TableHeader(header));
}
}
return table;
}
示例5: toString
import org.springframework.shell.support.table.Table; //导入依赖的package包/类
@Override
public String toString() {
Table table = new Table();
for (int i = 0; i < header.length; i++) {
table.addHeader(i + 1, new TableHeader(header[i]));
}
for (T element : collection) {
for (String[] row : provider.getRows(element)) {
table.addRow(row);
}
}
return TableRenderer.renderTextTable(table);
}
示例6: format
import org.springframework.shell.support.table.Table; //导入依赖的package包/类
private static String format(Table table) {
table.calculateColumnWidths();
return table.toString();
}