
io.gitee.ludii.excel.read.metadata.data.ReadCellData Maven / Gradle / Ivy
/*
* Copyright https://yuque.com/easyexcel All rights reserved.
*/
package io.gitee.ludii.excel.read.metadata.data;
import io.gitee.ludii.excel.enums.CellDataTypeEnum;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author 陆迪
* @date 2022/4/24
*/
@Setter
@Getter
@EqualsAndHashCode(callSuper = true)
public class ReadCellData extends AbstractBaseCellData {
private CellDataTypeEnum type;
private BigDecimal numberValue;
private String stringValue;
private Boolean booleanValue;
private Date dateValue;
/**
* The resulting converted data.
*/
private T data;
public ReadCellData(CellDataTypeEnum type) {
super();
if (type == null) {
throw new IllegalArgumentException("Type can not be null");
}
setType(type);
}
public ReadCellData(T data) {
super();
setData(data);
}
public ReadCellData(String stringValue) {
this(CellDataTypeEnum.STRING, stringValue);
}
public ReadCellData(CellDataTypeEnum type, String stringValue) {
super();
if (type != CellDataTypeEnum.STRING && type != CellDataTypeEnum.ERROR) {
throw new IllegalArgumentException("Only support CellDataTypeEnum.STRING and CellDataTypeEnum.ERROR");
}
if (stringValue == null) {
throw new IllegalArgumentException("StringValue can not be null");
}
setType(type);
setStringValue(stringValue);
}
public ReadCellData(BigDecimal numberValue) {
super();
if (numberValue == null) {
throw new IllegalArgumentException("DoubleValue can not be null");
}
setType(CellDataTypeEnum.NUMBER);
setNumberValue(numberValue);
}
public ReadCellData(Boolean booleanValue) {
super();
if (booleanValue == null) {
throw new IllegalArgumentException("BooleanValue can not be null");
}
setType(CellDataTypeEnum.BOOLEAN);
setBooleanValue(booleanValue);
}
public static ReadCellData> newEmptyInstance() {
return newEmptyInstance(null, null);
}
public static ReadCellData> newEmptyInstance(Integer rowIndex, Integer columnIndex) {
ReadCellData> cellData = new ReadCellData<>(CellDataTypeEnum.EMPTY);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static ReadCellData> newInstance(Boolean booleanValue) {
return newInstance(booleanValue, null, null);
}
public static ReadCellData> newInstance(Boolean booleanValue, Integer rowIndex, Integer columnIndex) {
ReadCellData> cellData = new ReadCellData<>(booleanValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static ReadCellData> newInstance(String stringValue, Integer rowIndex, Integer columnIndex) {
ReadCellData> cellData = new ReadCellData<>(stringValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static ReadCellData> newInstance(BigDecimal numberValue, Integer rowIndex, Integer columnIndex) {
ReadCellData> cellData = new ReadCellData<>(numberValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy