All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bdeploy.common.cli.data.DataTableRowBuilder Maven / Gradle / Ivy

Go to download

Public API including dependencies, ready to be used for integrations and plugins.

There is a newer version: 7.4.0
Show newest version
package io.bdeploy.common.cli.data;

import java.util.ArrayList;
import java.util.List;

/**
 * Builds a table row cell by cell.
 */
public class DataTableRowBuilder {

    private final DataTable target;
    private final List cells = new ArrayList<>();

    DataTableRowBuilder(DataTable target) {
        this.target = target;
    }

    /**
     * @param data a cell to add. If the cell is a {@link DataTableCell} it is applied as is, otherwise {@link #toString()} is
     *            called on the data.
     */
    public DataTableRowBuilder cell(Object data) {
        if (data instanceof DataTableCell) {
            cells.add((DataTableCell) data);
        } else {
            cells.add(new DataTableCell(data));
        }
        return this;
    }

    public DataTable build() {
        target.row(cells);
        return target;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy