package org.hzhub.workflow.workflow.def;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hzhub.workflow.enums.WfIODataTypeEnum;
import org.hzhub.workflow.workflow.data.NodeIOData;
import org.hzhub.workflow.workflow.data.NodeIODataFilesContent;
import org.springframework.util.CollectionUtils;

/**
 * 用户输入参数-文件列表类型 参数定义
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class WfNodeIOFiles extends WfNodeIO {
    protected Integer type = WfIODataTypeEnum.FILES.getValue();
    private Integer limit;

    @Override
    public boolean checkValue(NodeIOData data) {
        if (!(data.getContent() instanceof NodeIODataFilesContent wfNodeIOFiles)) {
            return false;
        }
        return !required || !CollectionUtils.isEmpty(wfNodeIOFiles.getValue());
    }
}
