Skip to content

Commit 28d426c

Browse files
authored
Merge pull request #10 from JavaWebStack/add-mapping-for-number
Added support for the Number type
2 parents 99003a9 + 73288a1 commit 28d426c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/org/javawebstack/abstractdata/mapper/DefaultMappers.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.javawebstack.abstractdata.util.Helpers;
77

88
import java.sql.Timestamp;
9+
import java.text.NumberFormat;
910
import java.text.ParseException;
1011
import java.util.*;
1112
import java.util.concurrent.*;
@@ -45,6 +46,7 @@ public static Map<Class<?>, MapperTypeAdapter> create() {
4546
map.put(double.class, PRIMITIVE);
4647
map.put(Boolean.class, PRIMITIVE);
4748
map.put(boolean.class, PRIMITIVE);
49+
map.put(Number.class, PRIMITIVE);
4850
map.put(Map.class, MAP);
4951
map.put(HashMap.class, MAP);
5052
map.put(LinkedHashMap.class, MAP);
@@ -117,6 +119,8 @@ public Object fromAbstract(MapperContext context, AbstractElement element, Class
117119
return element.number().floatValue();
118120
if(type.equals(byte.class) || type.equals(Byte.class))
119121
return element.number().byteValue();
122+
if(type.equals(Number.class))
123+
return element.number();
120124
return element.number();
121125
}
122126
throw new MapperWrongTypeException(context.getField().getName(), "primitive", Helpers.typeName(element));

0 commit comments

Comments
 (0)