• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wz2cool / mybatis-dynamic-query / #393

19 May 2024 12:06PM CUT coverage: 72.18% (-17.3%) from 89.44%
#393

push

wz2cool
add ci

1977 of 2739 relevant lines covered (72.18%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.79
/src/main/java/com/github/wz2cool/dynamic/mybatis/TypeHelper.java
1
package com.github.wz2cool.dynamic.mybatis;
2

3
import java.math.BigDecimal;
4
import java.util.Date;
5

6
/**
7
 * @author Frank
8
 **/
9
public class TypeHelper {
10
    private TypeHelper() {
×
11
    }
×
12

13
    public static BigDecimal getBigDecimal(Object value) {
14
        BigDecimal ret = null;
1✔
15
        if (value != null) {
1✔
16
            if (value instanceof BigDecimal) {
1✔
17
                ret = (BigDecimal)value;
1✔
18
            } else {
19
                ret = new BigDecimal(value.toString());
×
20
            }
21
        }
22

23
        return ret;
1✔
24
    }
25

26
    public static Byte getByte(Object value) {
27
        Byte ret = null;
×
28
        if (value != null) {
×
29
            if (value instanceof Byte) {
×
30
                ret = (Byte)value;
×
31
            } else {
32
                ret = new Byte(value.toString());
×
33
            }
34
        }
35

36
        return ret;
×
37
    }
38

39
    public static Date getDate(Object value) {
40
        Date ret = null;
×
41
        if (value != null) {
×
42
            if (!(value instanceof Date)) {
×
43
                throw new ClassCastException("Not possible to coerce [" + value + "] from class " + value.getClass() + " into a Date.");
×
44
            }
45

46
            ret = (Date)value;
×
47
        }
48

49
        return ret;
×
50
    }
51

52
    public static Double getDouble(Object value) {
53
        Double ret = null;
×
54
        if (value != null) {
×
55
            if (value instanceof Double) {
×
56
                ret = (Double)value;
×
57
            } else {
58
                ret = new Double(value.toString());
×
59
            }
60
        }
61

62
        return ret;
×
63
    }
64

65
    public static Float getFloat(Object value) {
66
        Float ret = null;
×
67
        if (value != null) {
×
68
            if (value instanceof Float) {
×
69
                ret = (Float)value;
×
70
            } else {
71
                ret = new Float(value.toString());
×
72
            }
73
        }
74

75
        return ret;
×
76
    }
77

78
    public static Integer getInteger(Object value) {
79
        Integer ret = null;
1✔
80
        if (value != null) {
1✔
81
            if (value instanceof Integer) {
1✔
82
                ret = (Integer)value;
1✔
83
            } else {
84
                ret = new Integer(value.toString());
×
85
            }
86
        }
87

88
        return ret;
1✔
89
    }
90

91
    public static Long getLong(Object value) {
92
        Long ret = null;
1✔
93
        if (value != null) {
1✔
94
            if (value instanceof Long) {
1✔
95
                ret = (Long)value;
×
96
            } else {
97
                ret = new Long(value.toString());
1✔
98
            }
99
        }
100

101
        return ret;
1✔
102
    }
103

104
    public static Short getShort(Object value) {
105
        Short ret = null;
×
106
        if (value != null) {
×
107
            if (value instanceof Short) {
×
108
                ret = (Short)value;
×
109
            } else {
110
                ret = new Short(value.toString());
×
111
            }
112
        }
113

114
        return ret;
×
115
    }
116

117
    public static String getString(Object value) {
118
        String ret = null;
×
119
        if (value != null) {
×
120
            if (value instanceof String) {
×
121
                ret = (String)value;
×
122
            } else {
123
                ret = value.toString();
×
124
            }
125
        }
126

127
        return ret;
×
128
    }
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc