org.cloudsimplus.builders.tables.AbstractTable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudsim-plus Show documentation
Show all versions of cloudsim-plus Show documentation
CloudSim Plus: A modern, highly extensible and easier-to-use Java 8 Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services
/*
* CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for
* Modeling and Simulation of Cloud Computing Infrastructures and Services.
* http://cloudsimplus.org
*
* Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and
* the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil).
*
* This file is part of CloudSim Plus.
*
* CloudSim Plus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CloudSim Plus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CloudSim Plus. If not, see .
*/
package org.cloudsimplus.builders.tables;
import org.apache.commons.lang3.StringUtils;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static java.util.stream.Collectors.toList;
/**
* An abstract base class for implementing data tables.
*
* @author Manoel Campos da Silva Filho
*/
public abstract class AbstractTable implements Table {
private PrintStream printStream;
/** @see #getColumns() */
private final List columns;
/** @see #getTitle() */
private String title;
/** @see #getRows() */
private final List> rows;
/**
* @see #getColumnSeparator()
*/
private String columnSeparator;
public AbstractTable(){
this("");
}
/**
* Creates a Table
* @param title Title of the table
*/
public AbstractTable(final String title){
this.printStream = System.out;
this.columns = new ArrayList<>();
this.rows = new ArrayList<>();
setTitle(title);
}
/**
* @return the list of columns of the table
*/
@Override
public List getColumns() {
return columns;
}
@Override
public String getTitle() {
return title;
}
@Override
public final Table setTitle(final String title) {
this.title = Objects.requireNonNull(title);
return this;
}
@Override
public String getColumnSeparator(){
return columnSeparator;
}
@Override
public final Table setColumnSeparator(String columnSeparator) {
this.columnSeparator = columnSeparator;
return this;
}
/**
* @return The data to be printed, where each row contains
* a list of data columns.
*/
protected List> getRows() {
return rows;
}
@Override
public List