Browse Source

添加 BigIntegerExt 扩展 BigInteger

James 2 years ago
parent
commit
d8343f18de

+ 6 - 0
src/main/java/com/jfinal/template/ext/extensionmethod/ByteExt.java

@@ -16,6 +16,8 @@
 
 package com.jfinal.template.ext.extensionmethod;
 
+import java.math.BigInteger;
+
 /**
  * 针对 java.lang.Byte 的扩展方法
  *
@@ -51,6 +53,10 @@ public class ByteExt {
 	public Byte toByte(Byte self) {
 		return self;
 	}
+
+	public BigInteger toBigInteger(Byte self) {
+		return BigInteger.valueOf(self);
+	}
 }
 
 

+ 6 - 0
src/main/java/com/jfinal/template/ext/extensionmethod/DoubleExt.java

@@ -16,6 +16,8 @@
 
 package com.jfinal.template.ext.extensionmethod;
 
+import java.math.BigInteger;
+
 /**
  * 针对 java.lang.Double 的扩展方法
  *
@@ -51,6 +53,10 @@ public class DoubleExt {
 	public Byte toByte(Double self) {
 		return self.byteValue();
 	}
+
+	public BigInteger toBigInteger(Double self) {
+		return BigInteger.valueOf(self.longValue());
+	}
 }
 
 

+ 6 - 0
src/main/java/com/jfinal/template/ext/extensionmethod/FloatExt.java

@@ -16,6 +16,8 @@
 
 package com.jfinal.template.ext.extensionmethod;
 
+import java.math.BigInteger;
+
 /**
  * 针对 java.lang.Float 的扩展方法
  *
@@ -51,6 +53,10 @@ public class FloatExt {
 	public Byte toByte(Float self) {
 		return self.byteValue();
 	}
+
+	public BigInteger toBigInteger(Float self) {
+		return BigInteger.valueOf(self.longValue());
+	}
 }
 
 

+ 6 - 0
src/main/java/com/jfinal/template/ext/extensionmethod/IntegerExt.java

@@ -16,6 +16,8 @@
 
 package com.jfinal.template.ext.extensionmethod;
 
+import java.math.BigInteger;
+
 /**
  * 针对 java.lang.Integer 的扩展方法
  *
@@ -71,6 +73,10 @@ public class IntegerExt {
 	public Byte toByte(Integer self) {
 		return self.byteValue();
 	}
+
+	public BigInteger toBigInteger(Integer self) {
+		return BigInteger.valueOf(self);
+	}
 }
 
 

+ 6 - 0
src/main/java/com/jfinal/template/ext/extensionmethod/LongExt.java

@@ -16,6 +16,8 @@
 
 package com.jfinal.template.ext.extensionmethod;
 
+import java.math.BigInteger;
+
 /**
  * 针对 java.lang.Long 的扩展方法
  *
@@ -51,6 +53,10 @@ public class LongExt {
 	public Byte toByte(Long self) {
 		return self.byteValue();
 	}
+
+	public BigInteger toBigInteger(Long self) {
+		return BigInteger.valueOf(self);
+	}
 }
 
 

+ 6 - 0
src/main/java/com/jfinal/template/ext/extensionmethod/ShortExt.java

@@ -16,6 +16,8 @@
 
 package com.jfinal.template.ext.extensionmethod;
 
+import java.math.BigInteger;
+
 /**
  * 针对 java.lang.Short 的扩展方法
  *
@@ -51,6 +53,10 @@ public class ShortExt {
 	public Byte toByte(Short self) {
 		return self.byteValue();
 	}
+
+	public BigInteger toBigInteger(Short self) {
+		return BigInteger.valueOf(self);
+	}
 }
 
 

+ 6 - 0
src/main/java/com/jfinal/template/ext/extensionmethod/StringExt.java

@@ -18,6 +18,8 @@ package com.jfinal.template.ext.extensionmethod;
 
 import com.jfinal.kit.StrKit;
 
+import java.math.BigInteger;
+
 /**
  * 针对 java.lang.String 的扩展方法
  *
@@ -87,6 +89,10 @@ public class StringExt {
 	public Byte toByte(String self) {
 		return StrKit.isBlank(self) ? null : Byte.parseByte(self);
 	}
+
+	public BigInteger toBigInteger(String self) {
+		return new BigInteger(self);
+	}
 }