shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
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.iplatform.core;
 
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.walker.infrastructure.arguments.Variable;
import com.walker.infrastructure.arguments.VariableType;
import com.walker.infrastructure.utils.StringUtils;
 
/**
 * 在 Redis 中使用的并存储的参数变量对象。
 * @author 时克英
 * @date 2022-11-29
 */
public class SimpleVariable implements Variable {
 
//    @JsonIgnore
//    private String description = StringUtils.EMPTY_STRING;
//    @JsonIgnore
//    private int integerValue = 0;
//    @JsonIgnore
//    private boolean booleanValue = false;
//    @JsonIgnore
//    private float floatValue = 0F;
//    @JsonIgnore
//    private long longValue = 0;
//    @JsonIgnore
//    private double doubleValue = 0.0;
 
    private String dataType = VariableType.DEF_STRING;
 
    private String stringValue;
 
    // 数据key
    private String id;
 
    public SimpleVariable(){}
 
    public SimpleVariable(String id, String value){
        this.id = id;
        this.stringValue = value;
    }
 
    public void setId(String id) {
        this.id = id;
    }
 
    public void setStringValue(String stringValue) {
        this.stringValue = stringValue;
    }
 
    @Override
    public String getId() {
        return this.id;
    }
 
    @JsonIgnore
    @Override
    public String getDescription() {
//        return this.description;
        return null;
    }
 
    @JsonIgnore
    @Override
    public VariableType getType() {
        if(StringUtils.isNotEmpty(this.dataType)){
            return VariableType.getType(this.dataType);
        }
        return null;
    }
 
    @Override
    public String getStringValue() {
        return this.stringValue;
    }
 
    @JsonIgnore
    @Override
    public int getIntegerValue() {
//        return this.integerValue;
        return Integer.parseInt(this.stringValue);
    }
 
    @JsonIgnore
    @Override
    public boolean getBooleanValue() {
//        return this.booleanValue;
        return Boolean.valueOf(this.stringValue);
    }
 
    @JsonIgnore
    @Override
    public float getFloatValue() {
//        return this.floatValue;
        return Float.parseFloat(this.stringValue);
    }
 
    @JsonIgnore
    @Override
    public long getLongValue() {
//        return this.longValue;
        return Long.parseLong(this.stringValue);
    }
 
    @JsonIgnore
    @Override
    public double getDoubleValue() {
//        return this.doubleValue;
        return Double.parseDouble(this.stringValue);
    }
 
    @JsonIgnore
    @Override
    public Object getDefaultValue() {
        return null;
    }
 
    public String getDataType() {
        return dataType;
    }
 
    public void setDataType(String dataType) {
        this.dataType = dataType;
    }
}