@@ -48,24 +48,12 @@ private Utils() {
48
48
* @return the int represented by the string, or zero if conversion fails
49
49
*/
50
50
public static int getInt (String string ) {
51
- return getInt (string , 0 );
52
- }
53
-
54
- /**
55
- * Convert a String to an int, returning a default value if the conversion
56
- * fails. If the string is null, the default value is returned.
57
- *
58
- * @param string the string to convert, may be null
59
- * @param def the default value
60
- * @return the int represented by the string, or the default if conversion fails
61
- */
62
- public static int getInt (String string , int def ) {
63
- if (string == null ) return def ;
51
+ if (string == null ) return 0 ;
64
52
65
53
try {
66
54
return Integer .parseInt (string );
67
55
} catch (NumberFormatException ignored ) {
68
- return def ;
56
+ return 0 ;
69
57
}
70
58
}
71
59
@@ -77,24 +65,12 @@ public static int getInt(String string, int def) {
77
65
* @return the double represented by the string, or zero if conversion fails
78
66
*/
79
67
public static double getDouble (String string ) {
80
- return getDouble (string , 0 );
81
- }
82
-
83
- /**
84
- * Convert a String to a double, returning a default value if the conversion
85
- * fails. If the string is null, the default value is returned.
86
- *
87
- * @param string the string to convert, may be null
88
- * @param def the default value
89
- * @return the double represented by the string, or the default if conversion fails
90
- */
91
- public static double getDouble (String string , double def ) {
92
- if (string == null ) return def ;
68
+ if (string == null ) return 0d ;
93
69
94
70
try {
95
71
return Double .parseDouble (string );
96
72
} catch (NumberFormatException ignored ) {
97
- return def ;
73
+ return 0d ;
98
74
}
99
75
}
100
76
@@ -106,24 +82,12 @@ public static double getDouble(String string, double def) {
106
82
* @return the long represented by the string, or zero if conversion fails
107
83
*/
108
84
public static long getLong (String string ) {
109
- return getLong (string , 0 );
110
- }
111
-
112
- /**
113
- * Convert a String to a long, returning a default value if the conversion
114
- * fails. If the string is null, the default value is returned.
115
- *
116
- * @param string the string to convert, may be null
117
- * @param def the default value
118
- * @return the long represented by the string, or the default if conversion fails
119
- */
120
- public static long getLong (String string , long def ) {
121
- if (string == null ) return def ;
85
+ if (string == null ) return 0L ;
122
86
123
87
try {
124
88
return Long .parseLong (string );
125
89
} catch (NumberFormatException ignored ) {
126
- return def ;
90
+ return 0L ;
127
91
}
128
92
}
129
93
@@ -135,24 +99,12 @@ public static long getLong(String string, long def) {
135
99
* @return the float represented by the string, or zero if conversion fails
136
100
*/
137
101
public static float getFloat (String string ) {
138
- return getFloat (string , 0 );
139
- }
140
-
141
- /**
142
- * Convert a String to a float, returning a default value if the conversion
143
- * fails. If the string is null, the default value is returned.
144
- *
145
- * @param string the string to convert, may be null
146
- * @param def the default value
147
- * @return the float represented by the string, or the default if conversion fails
148
- */
149
- public static float getFloat (String string , float def ) {
150
- if (string == null ) return def ;
102
+ if (string == null ) return 0F ;
151
103
152
104
try {
153
105
return Float .parseFloat (string );
154
106
} catch (NumberFormatException ignored ) {
155
- return def ;
107
+ return 0F ;
156
108
}
157
109
}
158
110
0 commit comments