package com.ga.common.excel;

import com.ga.common.annotation.ExcelColumn;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * VO 클래스 → @ExcelColumn 메타정보 추출.
 */
public final class ExcelColumnParser {

    private ExcelColumnParser() {}

    public static List<ExcelColumnInfo> parse(Class<?> clazz) {
        List<ExcelColumnInfo> list = new ArrayList<>();
        for (Field f : clazz.getDeclaredFields()) {
            ExcelColumn ann = f.getAnnotation(ExcelColumn.class);
            if (ann != null) list.add(ExcelColumnInfo.of(f, ann));
        }
        list.sort(Comparator.comparingInt(ExcelColumnInfo::getOrder));
        return list;
    }
}
