Skip to content

Commit

Permalink
add support for castToBigInteger in TypeUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-huang authored and wenshao committed Feb 25, 2023
1 parent 73f81c0 commit 6551ec5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -585,6 +586,10 @@ public static BigDecimal castToBigDecimal(Object value) {
return com.alibaba.fastjson2.util.TypeUtils.toBigDecimal(value);
}

public static BigInteger castToBigInteger(Object value) {
return com.alibaba.fastjson2.util.TypeUtils.toBigInteger(value);
}

public static Timestamp castToTimestamp(final Object value) {
return com.alibaba.fastjson2.util.TypeUtils.cast(value, Timestamp.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void cast1() {
assertNull(TypeUtils.castToLong(null));
assertNull(TypeUtils.castToDouble(null));
assertNull(TypeUtils.castToBigDecimal(null));
assertNull(TypeUtils.castToBigInteger(null));
assertNull(TypeUtils.castToTimestamp(null));
assertNull(TypeUtils.castToSqlDate(null));
assertNull(TypeUtils.castToJavaBean(null, null));
Expand Down

0 comments on commit 6551ec5

Please sign in to comment.