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

cloud.agileframework.common.util.file.poi.SheetData Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package cloud.agileframework.common.util.file.poi;

import com.google.common.collect.Lists;

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

/**
 * @author on 2018/10/16
 * @author 佟盟
 * sheet页信息
 */
public class SheetData {
    //sheet 页名
    private String name;
    //字段头信息
    private List cells;
    //所有行数据
    private List data;

    public SheetData() {
    }

    public SheetData(String name, List cells, List data) {
        this.name = name;
        this.cells = cells;
        this.data = data;
    }

    private SheetData(Builder builder) {
        this.name = builder.name;
        this.cells = builder.cells;
        this.data = builder.data;
    }

    public static Builder builder() {
        return new Builder();
    }

    public String getName() {
        if (name == null) {
            return "数据";
        }
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List getData() {
        return data;
    }

    public void setData(List data) {
        this.data = data;
    }

    public List getCells() {
        return cells;
    }

    public void setCells(List cells) {
        this.cells = cells;
    }

    public SheetData addCell(CellInfo cell) {
        if (cells == null) {
            cells = Lists.newCopyOnWriteArrayList();
        }
        this.cells.add(cell);
        return this;
    }

    /**
     * 建造者
     */
    public static class Builder {
        private String name;
        private List cells;
        private List data;

        public Builder setName(String name) {
            this.name = name;
            return this;
        }

        public Builder setCells(List cells) {
            this.cells = cells;
            return this;
        }

        public Builder setData(List data) {
            this.data = data;
            return this;
        }

        public SheetData build() {
            return new SheetData(this);
        }
    }
}