package com.ruoyi.web.modules.industryservice.support;

import java.time.Year;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 填报年份选项（当年起向前 5 年，共 6 个）
 */
public final class YakHerdInventoryYearSupport
{
    private YakHerdInventoryYearSupport()
    {
    }

    public static List<Integer> resolveYearOptions()
    {
        return resolveYearOptions(Year.now().getValue());
    }

    public static List<Integer> resolveYearOptions(int currentYear)
    {
        List<Integer> years = new ArrayList<>();
        for (int y = currentYear; y >= currentYear - YakHerdInventoryRules.YEAR_LOOKBACK; y--)
        {
            years.add(y);
        }
        return Collections.unmodifiableList(years);
    }

    public static boolean isAllowedYear(Integer statYear)
    {
        if (statYear == null)
        {
            return false;
        }
        return resolveYearOptions().contains(statYear);
    }
}
