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

net.sixpointsix.carpo.common.model.ListDataSet Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show newest version
package net.sixpointsix.carpo.common.model;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Immutable data set to be used in a data parser
 *
 * @author Andrew Tarry
 * @since 0.2.0
 */
public class ListDataSet implements DataSet {

    private final List dataPointRowList;

    public ListDataSet(List dataPointRowList) {
        this.dataPointRowList = dataPointRowList;
    }

    /**
     * Get the list of rows
     * @return rows in the set
     */
    @Override
    public List getRows() {
        return dataPointRowList;
    }

    /**
     * Get all the headers in the data set
     *
     * 

* This method assumes the headers are consistent since a csv could not support anything else *

* @return list of the headers */ @Override public List getHeaders() { if(dataPointRowList == null || dataPointRowList.isEmpty()) { return List.of(); } return dataPointRowList .get(0) .stream() .map(DataPoint::getColumn) .collect(Collectors.toList()); } /** * Test if the list of rows is empty * @return true if empty */ @Override public boolean isEmpty() { return dataPointRowList.isEmpty(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy