elkers
2025-04-07 bd9808a81b1eafdc75a42c1c9904408dc888061d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.nanjing.water.common.validator;
 
import java.util.function.Function;
 
/**
 * 参数验证 对象
 * @author linliu
 * @date   2019-04-19
 * @param <T> 枚举类型
 */
public class ParameterValidateItem<T extends Enum> {
    private String fieldName;
    private EParameterValidateType type;
    private Object value;
    private Object rangeMin;
    private Object rangeMax;
    private Class<T> enumType;
    private Function<Object, Boolean> validateFunc = null;
    private String regex;
 
    public ParameterValidateItem() {}
    public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value) {
        this.fieldName = fieldName;
        this.type = type;
        this.value = value;
    }
    public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Function<Object, Boolean> validateFunc) {
        this.fieldName = fieldName;
        this.type = type;
        this.value = value;
        this.validateFunc = validateFunc;
    }
    public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Object rangeMin, Object rangeMax) {
        this.fieldName = fieldName;
        this.type = type;
        this.value = value;
        this.rangeMin = rangeMin;
        this.rangeMax = rangeMax;
    }
    public ParameterValidateItem(String fieldName, EParameterValidateType type, Object value, Object rangeMin, Object rangeMax, Class<T> enumType) {
        this.fieldName = fieldName;
        this.type = type;
        this.value = value;
        this.rangeMin = rangeMin;
        this.rangeMax = rangeMax;
        this.enumType = enumType;
    }
    public ParameterValidateItem(String fieldName, Object value, Object rangeMin, Object rangeMax) {
        this.fieldName = fieldName;
        this.type = EParameterValidateType.MUST_IN_RANGE;
        this.value = value;
        this.rangeMin = rangeMin;
        this.rangeMax = rangeMax;
    }
    public ParameterValidateItem(String fieldName, Object value , Class<T> enumType) {
        this.fieldName = fieldName;
        this.type = EParameterValidateType.MUST_ENUM;
        this.value = value;
        this.enumType = enumType;
    }
    public ParameterValidateItem(String fieldName, Object value , String regex) {
        this.fieldName = fieldName;
        this.type = EParameterValidateType.MUST_PASS_REGEX;
        this.value = value;
        this.regex = regex;
    }
 
    public String getFieldName() {
        return fieldName;
    }
    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }
 
    public EParameterValidateType getType() {
        return type;
    }
    public void setType(EParameterValidateType type) {
        this.type = type;
    }
 
    public Object getValue() {
        return value;
    }
    public void setValue(Object value) {
        this.value = value;
    }
 
    public Object getRangeMin() {
        return rangeMin;
    }
    public void setRangeMin(Object rangeMin) {
        this.rangeMin = rangeMin;
    }
 
    public Object getRangeMax() {
        return rangeMax;
    }
    public void setRangeMax(Object rangeMax) {
        this.rangeMax = rangeMax;
    }
 
    public Class<T> getEnumType() {
        return enumType;
    }
    public void setEnumType(Class<T> enumType) {
        this.enumType = enumType;
    }
 
    public Function<Object, Boolean> getValidateFunc() {
        return validateFunc;
    }
    public void setValidateFunc(Function<Object, Boolean> validateFunc) {
        this.validateFunc = validateFunc;
    }
 
    public String getRegex() {
        return regex;
    }
 
    public void setRegex(String regex) {
        this.regex = regex;
    }
}