cn.schoolwow.util.domain.check.instanceList.CheckInstanceList Maven / Gradle / Ivy
The newest version!
package cn.schoolwow.util.domain.check.instanceList;
import cn.schoolwow.quickflow.QuickFlow;
import cn.schoolwow.quickflow.QuickFlowBuilder;
import cn.schoolwow.util.module.check.instanceList.flow.*;
import cn.schoolwow.util.module.check.instanceList.handler.CheckInstanceListTryCatchFinallyHandler;
import java.util.Arrays;
import java.util.List;
public class CheckInstanceList {
private static QuickFlow quickFlow = QuickFlowBuilder.newInstance()
.tryCatchFinallyHandler(new CheckInstanceListTryCatchFinallyHandler());
/**创建实例列表检查约束*/
public static CheckInstanceList newCheck(List list){
quickFlow.putContextThreadLocalData("list", list);
return new CheckInstanceList();
}
/**
* 非空检查
* @param fieldName 字段名
* @param message 提示信息
* */
public CheckInstanceList notNullCheck(String fieldName, String message){
quickFlow.startFlow(new CheckInstanceListNotNullFlow())
.putCurrentCompositeFlowData("fieldName", fieldName)
.putCurrentCompositeFlowData("message", message)
.execute();
return this;
}
/**
* 字符串或者列表非空检查
* @param fieldName 字段名
* @param message 提示信息
* */
public CheckInstanceList notEmptyCheck(String fieldName, String message){
quickFlow.startFlow(new CheckInstanceListNotEmptyFlow())
.putCurrentCompositeFlowData("fieldName", fieldName)
.putCurrentCompositeFlowData("message", message)
.execute();
return this;
}
/**
* 字段范围检查
* @param fieldName 字段名
* @param allowValueList 允许值列表
* @param message 提示信息
* */
public CheckInstanceList inValueCheck(String fieldName, List allowValueList, String message){
quickFlow.startFlow(new CheckInstanceListInValueListFlow())
.putCurrentCompositeFlowData("fieldName", fieldName)
.putCurrentCompositeFlowData("allowValueList", allowValueList)
.putCurrentCompositeFlowData("message", message)
.execute();
return this;
}
/**
* 字段重复值检查
* @param fieldNames 字段名列表
* @param message 提示信息
* */
public CheckInstanceList notRepeatCheck(List fieldNames, String message){
quickFlow.startFlow(new CheckInstanceListNotRepeatFlow())
.putCurrentCompositeFlowData("fieldNames", fieldNames)
.putCurrentCompositeFlowData("message", message)
.execute();
return this;
}
/**
* id字段值检查是否大于0
* @param idFieldName id字段名
* @param message 提示信息
* */
public CheckInstanceList idFieldCheck(String idFieldName, String message){
quickFlow.startFlow(new CheckInstanceListIdFieldFlow())
.putCurrentCompositeFlowData("idFieldName", idFieldName)
.putCurrentCompositeFlowData("message", message)
.execute();
return this;
}
/**
* 列表包含值检查
* @param fieldName id字段名
* @param containValue 包含值
* @param message 提示信息
* */
public CheckInstanceList containValueCheck(String fieldName, Object containValue, String message){
containValueListCheck(fieldName, Arrays.asList(containValue), message);
return this;
}
/**
* 列表包含值检查
* @param fieldName id字段名
* @param containValueList 包含值列表
* @param message 提示信息
* */
public CheckInstanceList containValueListCheck(String fieldName, List containValueList, String message){
quickFlow.startFlow(new CheckInstanceListContainValueFlow())
.putCurrentCompositeFlowData("fieldName", fieldName)
.putCurrentCompositeFlowData("containValueList", containValueList)
.putCurrentCompositeFlowData("message", message)
.execute();
return this;
}
}