// Path: src/main/java/br/com/tecsinapse/dataio/util/WorkbookUtil.java
// public static XSSFColor toXSSFColor(final HSSFColor hssfColor) {
//     return new XSSFColor(Color.decode(StyleColorUtil.toHexColor(hssfColor)), new DefaultIndexedColorMap());
// }


import static br.com.tecsinapse.dataio.util.WorkbookUtil.toXSSFColor;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/*
 * Tecsinapse Data Input and Output
 *
 * License: GNU Lesser General Public License (LGPL), version 3 or later
 * See the LICENSE file in the root directory or <http://www.gnu.org/licenses/lgpl-3.0.html>.
 */

package br.com.tecsinapse.dataio.style;




@Getter
@Setter
@EqualsAndHashCode
public class CellStyleBorder {

    private HSSFColor borderColor;
    private boolean left;
    private boolean right;
    private boolean top;
    private boolean bottom;
    private short size = 1;

    public CellStyleBorder(boolean left, boolean right, boolean top, boolean bottom) {
        this(Colors.BLACK, left, right, top, bottom);
    }

    public CellStyleBorder(HSSFColor borderColor, boolean left, boolean right, boolean top, boolean bottom) {
        this.borderColor = borderColor;
        this.left = left;
        this.right = right;
        this.top = top;
        this.bottom = bottom;
    }


    public CellStyle toCellStyle(CellStyle cellStyle) {
        if (cellStyle == null || !left && !right && !bottom && !top) {
            return cellStyle;
        }
        if (left) {
            cellStyle.setBorderLeft(BorderStyle.THIN);
            if (cellStyle instanceof XSSFCellStyle) {
// Path: src/main/java/br/com/tecsinapse/dataio/util/WorkbookUtil.java
// public static XSSFColor toXSSFColor(final HSSFColor hssfColor) {
//     return new XSSFColor(Color.decode(StyleColorUtil.toHexColor(hssfColor)), new DefaultIndexedColorMap());
// }


// Path: src/main/java/br/com/tecsinapse/dataio/style/CellStyleBorder.java
import static br.com.tecsinapse.dataio.util.WorkbookUtil.toXSSFColor;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

/*
 * Tecsinapse Data Input and Output
 *
 * License: GNU Lesser General Public License (LGPL), version 3 or later
 * See the LICENSE file in the root directory or <http://www.gnu.org/licenses/lgpl-3.0.html>.
 */

package br.com.tecsinapse.dataio.style;




@Getter
@Setter
@EqualsAndHashCode
public class CellStyleBorder {

    private HSSFColor borderColor;
    private boolean left;
    private boolean right;
    private boolean top;
    private boolean bottom;
    private short size = 1;

    public CellStyleBorder(boolean left, boolean right, boolean top, boolean bottom) {
        this(Colors.BLACK, left, right, top, bottom);
    }

    public CellStyleBorder(HSSFColor borderColor, boolean left, boolean right, boolean top, boolean bottom) {
        this.borderColor = borderColor;
        this.left = left;
        this.right = right;
        this.top = top;
        this.bottom = bottom;
    }


    public CellStyle toCellStyle(CellStyle cellStyle) {
        if (cellStyle == null || !left && !right && !bottom && !top) {
            return cellStyle;
        }
        if (left) {
            cellStyle.setBorderLeft(BorderStyle.THIN);
            if (cellStyle instanceof XSSFCellStyle) {
                ((XSSFCellStyle)cellStyle).setLeftBorderColor(toXSSFColor(borderColor));