diff options
Diffstat (limited to 'src/main/java/com/iciql/util/Utils.java')
-rw-r--r-- | src/main/java/com/iciql/util/Utils.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/com/iciql/util/Utils.java b/src/main/java/com/iciql/util/Utils.java index 92ca825..64fe6b3 100644 --- a/src/main/java/com/iciql/util/Utils.java +++ b/src/main/java/com/iciql/util/Utils.java @@ -273,10 +273,22 @@ public class Utils { // convert from boolean to number
if (Boolean.class.isAssignableFrom(currentType)) {
Boolean b = (Boolean) o;
+ Integer n = b ? 1 : 0;
if (Number.class.isAssignableFrom(targetType)) {
- return b ? 1 : 0;
- }
- if (boolean.class.isAssignableFrom(targetType)) {
+ return n.intValue();
+ } else if (byte.class.isAssignableFrom(targetType)) {
+ return n.byteValue();
+ } else if (short.class.isAssignableFrom(targetType)) {
+ return n.shortValue();
+ } else if (int.class.isAssignableFrom(targetType)) {
+ return n.intValue();
+ } else if (long.class.isAssignableFrom(targetType)) {
+ return n.longValue();
+ } else if (float.class.isAssignableFrom(targetType)) {
+ return n.floatValue();
+ } else if (double.class.isAssignableFrom(targetType)) {
+ return n.doubleValue();
+ } else if (boolean.class.isAssignableFrom(targetType)) {
return b.booleanValue();
}
}
|