package com.ga.common.excel;

import com.ga.common.annotation.ExcelColumn;
import lombok.Builder;
import lombok.Getter;

import java.lang.reflect.Field;

@Getter
@Builder
public class ExcelColumnInfo {
    private final Field field;
    private final String header;
    private final int order;
    private final int width;
    private final String format;
    private final String codeGroup;
    private final boolean masked;
    private final String defaultValue;
    private final boolean required;

    public static ExcelColumnInfo of(Field field, ExcelColumn ann) {
        field.setAccessible(true);
        return ExcelColumnInfo.builder()
                .field(field)
                .header(ann.header())
                .order(ann.order())
                .width(ann.width())
                .format(ann.format())
                .codeGroup(ann.codeGroup())
                .masked(ann.masked())
                .defaultValue(ann.defaultValue())
                .required(ann.required())
                .build();
    }
}
