package dev.fyloz.trial.colorrecipesexplorer.xlsx.component;

import dev.fyloz.trial.colorrecipesexplorer.xlsx.component.cells.Cell;
import dev.fyloz.trial.colorrecipesexplorer.xlsx.component.cells.styles.IBiggerCell;
import dev.fyloz.trial.colorrecipesexplorer.xlsx.component.cells.styles.IFontCell;
import org.apache.poi.ss.usermodel.CellType;

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

public class Catalog {

    private List<String> content;

    public Catalog() {
        content = new ArrayList<>();
    }

    public void addContent(String value) {
        content.add(value);
    }

    public Collection<Cell> getCells() {
        Collection<Cell> cells = new ArrayList<>();

        int index = 1;
        for (String value : content) {
            cells.add(new CatalogValueCell(String.format("%s. %s", index, value)));

            index++;
        }

        return cells;
    }

    private class CatalogValueCell extends Cell implements IBiggerCell, IFontCell {

        private String value;

        public CatalogValueCell(String value) {
            super(CellType.STRING);

            this.value = value;
        }

        @Override
        public int getWidth() {
            return Document.WIDTH;
        }

        @Override
        public int getHeight() {
            return 1;
        }

        @Override
        public String getContentText() {
            return value;
        }

        @Override
        public boolean isCentered() {
            return false;
        }

        @Override
        public boolean isBold() {
            return false;
        }
    }

}
