package cn.stylefeng.team.meta.db.pojo.query;

import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class Group {

    @ChineseDescription("单个条件组合")
    private List<FilterItem> filters;

    public Group() {
    }

    public Group(List<FilterItem> filters) {
        validateNotEmpty(filters);
        this.filters = filters != null ? filters : new ArrayList<>();
    }

    private void validateNotEmpty(List<FilterItem> filterItems) {
        if (filterItems == null || filterItems.isEmpty()) {
            throw new IllegalArgumentException("Group must contain filters");
        }
    }
}
