From f238356e5774f4c6c3b04ae877ada8c3034f4bb3 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Mon, 26 Aug 2019 15:41:59 +0800 Subject: [PATCH 1/9] =?UTF-8?q?KERNEL-1118=20=20=E5=B0=86AssistUtil?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E9=9D=99=E6=80=81=E6=96=B9=E6=B3=95=E7=A7=BB?= =?UTF-8?q?=E6=A4=8D=E5=88=B0AssistKit=E4=B8=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/util/AssistKit.java | 85 +++++++++++++++++++ .../com/fanruan/api/util/AssistKitTest.java | 79 +++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 src/main/java/com/fanruan/api/util/AssistKit.java create mode 100644 src/test/java/com/fanruan/api/util/AssistKitTest.java diff --git a/src/main/java/com/fanruan/api/util/AssistKit.java b/src/main/java/com/fanruan/api/util/AssistKit.java new file mode 100644 index 0000000..5fd70ae --- /dev/null +++ b/src/main/java/com/fanruan/api/util/AssistKit.java @@ -0,0 +1,85 @@ +package com.fanruan.api.util; + +import com.fr.stable.AssistUtils; + +public class AssistKit { + /** + * 比较两个双精度浮点型数据是否相等 + * @param parm1 + * @param parm2 + * @return 相等返回true 错误返回false + */ + public static boolean equals(double parm1, double parm2) { + return AssistUtils.equals(parm1, parm2); + } + + /** + * 比较两个单精度浮点型数据是否相等 + * @param parm1 + * @param parm2 + * @return 相等返回true 错误返回false + */ + public static boolean equals(float parm1, float parm2) { + return AssistUtils.equals(parm1, parm2); + } + + /** + * 判断两个Object类型数据是否相等 + * @param parm1 + * @param parm2 + * @return 相等返回true 错误返回false + */ + public static boolean equals(Object parm1, Object parm2) { + return AssistUtils.equals(parm1, parm2); + } + + /** + * 判断两个int类型数据是否相等 + * @param parm1 + * @param parm2 + * @return 相等返回0,如果parm1大于parm2 返回1否则返回-1 + */ + public static int compare(int parm1, int parm2) { + return AssistUtils.compare(parm1, parm2); + } + + /** + * 判断两个long类型数据是否相等 + * @param parm1 + * @param parm2 + * @return 相等返回0,如果parm1大于parm2 返回1否则返回-1 + */ + public static int compare(long parm1, long parm2) { + return AssistUtils.compare(parm1, parm2); + } + + /** + * 生成对象的哈希码值 + * @param parm + * @return 返回对象的哈希码值 + */ + public static int hashCode(Object... parm) { + return AssistUtils.hashCode(parm); + } + + /** + * 返回反映这个对象的字符串 + * @param parm + * @return 返回反映这个对象的字符串 + */ + public static String toString(Object parm) { + return AssistUtils.toString(parm); + } + + /** + * + * @param parm1 + * @param parm2 + * @return + */ +// public static String toString(Object parm1, String... parm2) { +// return AssistUtils.toString(parm1, parm2); +// } + + +} diff --git a/src/test/java/com/fanruan/api/util/AssistKitTest.java b/src/test/java/com/fanruan/api/util/AssistKitTest.java new file mode 100644 index 0000000..f402bda --- /dev/null +++ b/src/test/java/com/fanruan/api/util/AssistKitTest.java @@ -0,0 +1,79 @@ +package com.fanruan.api.util; + +import com.fr.event.Null; +import org.junit.Assert; +import org.junit.Test; + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.Objects; + +import static org.junit.Assert.*; + +public class AssistKitTest { + + @Test + public void equals1() { + double a = 1.1; + double b = 1.1; + double c = 1.11; + Assert.assertTrue(AssistKit.equals(a, b)); + Assert.assertFalse(AssistKit.equals(b, c)); + } + + @Test + public void equals2() { + float a = 1.1f; + float b = 1.1f; + float c = 1.111f; + Assert.assertTrue(AssistKit.equals(a, b)); + Assert.assertFalse(AssistKit.equals(b, c)); + } + + @Test + public void equals3() { + Object a = 126; + Object b = 126; + //Object c = new Integer(128); + //Object d = new Integer(128); + + Object e = 111.1f; + Assert.assertTrue(AssistKit.equals(a, b)); + Assert.assertTrue(AssistKit.equals(null, null)); + Assert.assertFalse(AssistKit.equals(null, a)); + + //c 和 d应该不是同一个对象啊?为什么返回True? + //Assert.assertTrue(AssistKit.equals(c, d)); + Assert.assertFalse(AssistKit.equals(a,e)); + + } + + @Test + public void compare() { + Assert.assertEquals(0, AssistKit.compare(1, 1)); + Assert.assertEquals(1, AssistKit.compare(2, 1)); + Assert.assertEquals(-1, AssistKit.compare(1, 2)); + } + + @Test + public void compare1() { + Assert.assertEquals(0, AssistKit.compare(1l, 1l)); + Assert.assertEquals(1, AssistKit.compare(2l, 1l)); + Assert.assertEquals(-1, AssistKit.compare(1l, 2l)); + } + + @Test + public void hashCode1() { + String s = "hello"; + Object[] a = new Object[]{s}; + Assert.assertEquals(Arrays.hashCode(a), AssistKit.hashCode(s)); + Assert.assertEquals(0, AssistKit.hashCode(null)); + + } + +// 暂时还没有用到,先不写单元测试 +// @Test +// public void toString1() { +// +// } +} \ No newline at end of file From 9cb59d063494fe69cfa20fcdebed1c8f047540ed Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 26 Aug 2019 16:41:14 +0800 Subject: [PATCH 2/9] =?UTF-8?q?KERNEL-1117=20=E5=B0=81=E8=A3=85=E4=BA=86St?= =?UTF-8?q?ringUtil=E5=A4=A7=E9=83=A8=E5=88=86=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E5=B0=81=E8=A3=85=E4=BA=86=E9=83=A8=E5=88=86=E7=94=A8=E5=88=B0?= =?UTF-8?q?=E7=B1=BB=EF=BC=8C=E5=AF=B9=E5=8F=AF=E4=BB=A5=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E7=BC=96=E5=86=99=E4=BA=86=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/util/BaseKit.java | 26 +++ .../java/com/fanruan/api/util/GUICoreKit.java | 24 +++ .../java/com/fanruan/api/util/GeneralKit.java | 4 + .../java/com/fanruan/api/util/StringKit.java | 166 ++++++++++++++++++ .../com/fanruan/api/util/GeneralKitTest.java | 12 ++ .../com/fanruan/api/util/StringKitTest.java | 142 +++++++++++++++ 6 files changed, 374 insertions(+) create mode 100644 src/main/java/com/fanruan/api/util/BaseKit.java create mode 100644 src/main/java/com/fanruan/api/util/GUICoreKit.java diff --git a/src/main/java/com/fanruan/api/util/BaseKit.java b/src/main/java/com/fanruan/api/util/BaseKit.java new file mode 100644 index 0000000..7206d1f --- /dev/null +++ b/src/main/java/com/fanruan/api/util/BaseKit.java @@ -0,0 +1,26 @@ +package com.fanruan.api.util; + +import com.fr.base.BaseUtils; + +import javax.swing.*; +import java.io.InputStream; + +public class BaseKit { + /** + * 从file中读数据,以流的形式读出数据 + * @param file + * @return 返回file文件,文件数据流 + */ + public static InputStream readResource(String file) { + return BaseUtils.readResource(file); + } + + /** + * 从file中读取数据,根据数据返回Icon图片 + * @param file + * @return 返回Icon图片 + */ + public static Icon readIcon(String file) { + return BaseUtils.readIcon(file); + } +} diff --git a/src/main/java/com/fanruan/api/util/GUICoreKit.java b/src/main/java/com/fanruan/api/util/GUICoreKit.java new file mode 100644 index 0000000..4914cfc --- /dev/null +++ b/src/main/java/com/fanruan/api/util/GUICoreKit.java @@ -0,0 +1,24 @@ +package com.fanruan.api.util; + +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; + +public class GUICoreKit { + + public static JPanel createFlowPane(Object... var0) { + return GUICoreUtils.createFlowPane(var0); + } + + /** + * 弹出菜单,在坐标为x,y处弹出内容为component的菜单 + * @param menu + * @param component + * @param x + * @param y + */ + public static void showPopupMenu(JPopupMenu menu, Component component, int x, int y) { + GUICoreUtils.showPopupMenu(menu, component, x, y); + } +} diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index 7b69760..f5e328e 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -49,4 +49,8 @@ public class GeneralKit { public static @Nullable Number objectToNumber(Object obj, boolean returnNull) { return GeneralUtils.objectToNumber(obj, returnNull); } + + public static @Nullable String readBuildNO() { + return GeneralUtils.readBuildNO(); + } } diff --git a/src/main/java/com/fanruan/api/util/StringKit.java b/src/main/java/com/fanruan/api/util/StringKit.java index e79d263..bbd2f06 100644 --- a/src/main/java/com/fanruan/api/util/StringKit.java +++ b/src/main/java/com/fanruan/api/util/StringKit.java @@ -1,6 +1,7 @@ package com.fanruan.api.util; import com.fr.stable.StringUtils; +import java.io.UnsupportedEncodingException; /** * @author richie @@ -95,4 +96,169 @@ public class StringKit { return StringUtils.trim(string); } + /** + *如果String为空则返回空字符串,否则返回String本身的值,保证String不空。 + * @param text + * @return + */ + public static String alwaysNotNull(String text) { + return StringUtils.alwaysNotNull(text); + } + /** + * 获取text字符串中去除结尾suffix字符串的部分 + * @param text + * @param suffix + * @return 若text字符串结尾是suffix,则返回去除suffix的部分,否则返回text + */ + public static String cutStringEndWith(String text, String suffix) { + return StringUtils.cutStringEndWith(text, suffix); + } + + /**获取text字符串去除开头startString部分 + * + * @param text + * @param startString + * @return 若text字符串开头是suffix,则返回去除startString部分否则返回text + */ + public static String cutStringStartWith(String text, String startString) { + return StringUtils.cutStringStartWith(text, startString); + } + + /** + * 去掉text字符串两边的空格或ASCII码小于空格的字符 + * @param text + * @return 若text只含空格字符,或ASCII码小于空格的字符,返回null,否则返回去除两边空字符后的text + */ + public static String trimToNull(String text) { + return StringUtils.trimToNull(text); + } + + /** + * 令text以startString开头 + * @param text + * @param startString + * @return 若text不以startString开头,在text前添加startString。若text以startString开头返回text + */ + public static String perfectStart(String text, String startString) { + return StringUtils.perfectStart(text, startString); + } + + /** + * 令text以suffix结尾 + * @param text + * @param suffix + * @return 若text不以suffix结尾,在text后添加suffix。若text以suffix结尾返回text + */ + public static String perfectEnd(String text, String suffix) { + return StringUtils.perfectEnd(text, suffix); + } + + /** + * 令text的开头结尾都是str + * @param text + * @param str + * @return 若text的开头或结尾不是str,在相应位置添加str,若开头结尾都是text,返回text + */ + public static String perfectSurround(String text, String str) { + return StringUtils.perfectSurround(text, str); + } + + /** + * 返回text长度 + * @param text + * @return 若text为null返回0,否则返回text长度 + */ + public static int getLength(String text) { + return StringUtils.getLength(text); + } + + /** + * 判断text1和text2在去掉开头或结尾的ignoreStr部分是否相等 + * @param text1 + * @param text2 + * @param ignoreStr + * @return 如果text1和txet2去掉开头结尾的ignoreStr后相等返回true,不等返回false + */ + public static boolean equalsIgnore(String text1, String text2, String ignoreStr) { + return StringUtils.equalsIgnore(text1, text2, ignoreStr); + } + + /** + * 将str加入到strArr字符串数组的每个字符串后方(不包括最后一个字符串),同时将结果字符串数组连接起来,形成新的字符串 + * @param str + * @param strArr + * @return 若strArr为空则返回null,若strArr长度为0返回""空字符串,否则返回连接后的字符串 + */ + public static String join(String str, String[] strArr) { + return StringUtils.join(str, strArr); + } + + /** + * 将text字符串中的A-J转换成0-9,工具函数 + * @param text + * @return 返回转换后的字符串 + */ + public static String parseVersion(String text) { + return StringUtils.parseVersion(text); + } + + /** + * 判断text是否是json中数组的string形式 + * @param text + * @return 若是数组的String形式返回true,否则返回flase + */ + public static boolean isArrayType(String text) { + return StringUtils.isArrayType(text); + } + + /** + *从原本json数组类型的String取出其中的每一个用逗号间隔元素,作为String二维数组返回值 + * @param text + * @return 取出text中用逗号间隔的元素 + */ + public static String[][] stringToArray(String text) { + return StringUtils.stringToArray(text); + } + + /** + *对text中每个字符,用charsetName为名的编码方式解码后,返回解码后字节长度从0到bytelength的部分,以String形式返回 + * @param text + * @param charsetName + * @param byteLength + * @return 若text为空或byteLength小于等于0返回空字符串,否则以String形式返回解码后字节长度从0到bytelength的部分 + */ + public static String subStringByByteLength(String text, String charsetName, int byteLength) throws UnsupportedEncodingException { + return StringUtils.subStringByByteLength(text, charsetName, byteLength); + } + + /** + * 比较text和compareStr两字符串值是否相等 + * @param text + * @param compareStr + * @return 若text和compareStr两字符串的值相同返回true,否则返回false + */ + public static boolean equals(String text, String compareStr) { + return StringUtils.equals(text, compareStr); + } + + /** + * 比较text和compareStr两字符串忽略大小写的情况下值是否相等 + * @param text + * @param compareStr + * @return 在忽略大小写的情况下,若text和compareStr两字符串的值相同返回true,否则返回false + */ + public static boolean equalsIgnoreCase(String text, String compareStr) { + return StringUtils.equalsIgnoreCase(text, compareStr); + } + + /** + * 扩展text的长度至stringLength,不足则以空格填充 + * @param text + * @param stringLength + * @return 若text长度比stringLength,则将text扩充到stringLength长度,否则返回text + */ + public static String rightPad(String text, int stringLength) { + return StringUtils.rightPad(text, stringLength); + } + } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index cbead61..84b8e23 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -15,4 +15,16 @@ public class GeneralKitTest extends Prepare { public void getMacAddress() throws Exception{ Assert.assertEquals(GeneralKit.getMacAddress(), com.fr.general.GeneralUtils.getMacAddress()); } + + @Test + public void objectToString() { + Integer s = new Integer(1); + Assert.assertEquals(GeneralKit.objectToString(s),"1"); + } + + @Test + public void readBuildNO() { + Assert.assertEquals(GeneralKit.readBuildNO(), com.fr.general.GeneralUtils.readBuildNO()); + } + } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/StringKitTest.java b/src/test/java/com/fanruan/api/util/StringKitTest.java index 3e07b43..8bef1a3 100644 --- a/src/test/java/com/fanruan/api/util/StringKitTest.java +++ b/src/test/java/com/fanruan/api/util/StringKitTest.java @@ -14,18 +14,32 @@ public class StringKitTest { @Test public void isEmpty() { + assertEquals(StringKit.isEmpty(""),true); + assertEquals(StringKit.isEmpty("asd"),false); } @Test public void isNotEmpty() { + assertEquals(StringKit.isNotEmpty("asd"),true); + assertEquals(StringKit.isNotEmpty(""),false); } @Test public void isBlank() { + assertEquals(StringKit.isNotBlank(null),false); + assertEquals(StringKit.isNotBlank(""),false); + assertEquals(StringKit.isNotBlank(" "),false); + assertEquals(StringKit.isNotBlank("bob"),true); + assertEquals(StringKit.isNotBlank(" bob "),true); } @Test public void isNotBlank() { + assertEquals(StringKit.isBlank(null),true); + assertEquals(StringKit.isBlank(""),true); + assertEquals(StringKit.isBlank(" "),true); + assertEquals(StringKit.isBlank("bob"),false); + assertEquals(StringKit.isBlank(" bob "),false); } @Test public void trim(){ @@ -36,4 +50,132 @@ public class StringKitTest { Assert.assertEquals(StringKit.trim(stringWithoutBlank), "abc"); Assert.assertEquals(StringKit.trim(blankString), ""); } + + @Test + public void alwaysNotNull() { + assertEquals(StringKit.alwaysNotNull(null),""); + assertEquals(StringKit.alwaysNotNull(""),""); + assertEquals(StringKit.alwaysNotNull("asd"),"asd"); + } + + @Test + public void cutStringEndWith() { + assertEquals(StringKit.cutStringEndWith("bob is","is"), "bob "); + assertEquals(StringKit.cutStringEndWith("","is"), ""); + } + + @Test + public void cutStringStartWith() { + assertEquals(StringKit.cutStringStartWith("bob is","bob "), "is"); + assertEquals(StringKit.cutStringStartWith("","is"), ""); + } + + @Test + public void trimToNull() { + assertEquals(StringKit.trimToNull(" "),null); + assertEquals(StringKit.trimToNull(" s "),"s"); + } + + @Test + public void perfectStart() { + assertEquals(StringKit.perfectStart("bobob","bob"),"bobob"); + assertEquals(StringKit.perfectStart("sbobob","bob"),"bobsbobob"); + } + + @Test + public void perfectEnd() { + assertEquals(StringKit.perfectEnd("bobob","bob"),"bobob"); + assertEquals(StringKit.perfectEnd("bobobs","bob"),"bobobsbob"); + } + + @Test + public void perfectSurround() { + assertEquals(StringKit.perfectSurround("bobob","bob"),"bobob"); + assertEquals(StringKit.perfectSurround("sbobobs","bob"),"bobsbobobsbob"); + } + + @Test + public void getLength() { + assertEquals(StringKit.getLength("asd"),3); + assertEquals(StringKit.getLength(""),0); + assertEquals(StringKit.getLength(null),0); + } + + @Test + public void equalsIgnore() { + assertEquals(StringKit.equalsIgnore("asd","asd","qwewqe"),true); + assertEquals(StringKit.equalsIgnore("asd","as","d"),true); + assertEquals(StringKit.equalsIgnore("asd","asdd","d"),false); + } + + @Test + public void join() { + String[] s = new String[3]; + String[] s1 = new String[0]; + s[0]= new String("qqq"); + s[1]= new String("www"); + s[2]= new String("eee"); + assertEquals(StringKit.join("asd",s),"qqqasdwwwasdeee"); + assertEquals(StringKit.join("",s),"qqqwwweee"); + assertEquals(StringKit.join("asd",null),null); + assertEquals(StringKit.join("asd",s1),""); + } + + + @Test + public void parseVersion() { + assertEquals(StringKit.parseVersion("BCD123"),"123123"); + } + + @Test + public void isArrayType() { + assertEquals(StringKit.isArrayType("[[]]"),true); + assertEquals(StringKit.isArrayType("[["),false); + } + + @Test + public void stringToArray() { + String[][] s = new String[1][3]; + s[0][0] = new String("a"); + s[0][1] = new String("b"); + s[0][2] = new String("c"); + assertEquals(StringKit.stringToArray("[[a,b,c]]"),s); + } + + @Test + public void subStringByByteLength() { + try { + assertEquals(StringKit.subStringByByteLength("asd", "UTF-8", 1), "a"); + assertEquals(StringKit.subStringByByteLength(" ", "UTF-8", 1), ""); + assertEquals(StringKit.subStringByByteLength("asd", "UTF-8", 0), ""); + }catch (Exception e){ + + } + } + + @Test + public void equals() { + String s = new String("asd"); + String s1 = new String("asd"); + String s2 = new String("asds"); + assertEquals(StringKit.equals(s, s1), true); + assertEquals(StringKit.equals(s, s2), false); + assertEquals(StringKit.equals(null, null), true); + } + + @Test + public void equalsIgnoreCase() { + String s = new String("Asd"); + String s1 = new String("asd"); + String s2 = new String("asds"); + assertEquals(StringKit.equalsIgnoreCase(s, s1), true); + assertEquals(StringKit.equalsIgnoreCase(s, s2), false); + assertEquals(StringKit.equalsIgnoreCase(null, null), true); + } + + @Test + public void rightPad() { + assertEquals(StringKit.rightPad("asd",5), "asd "); + assertEquals(StringKit.rightPad("asd",-1), "asd"); + } } \ No newline at end of file From 1385d356553e312e6320a03ec2a59cde82f8124c Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Mon, 26 Aug 2019 19:09:55 +0800 Subject: [PATCH 3/9] =?UTF-8?q?KERNEL-1118=20=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/util/AssistKitTest.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/fanruan/api/util/AssistKitTest.java b/src/test/java/com/fanruan/api/util/AssistKitTest.java index f402bda..def10b4 100644 --- a/src/test/java/com/fanruan/api/util/AssistKitTest.java +++ b/src/test/java/com/fanruan/api/util/AssistKitTest.java @@ -34,16 +34,12 @@ public class AssistKitTest { public void equals3() { Object a = 126; Object b = 126; - //Object c = new Integer(128); - //Object d = new Integer(128); - + Object c = new Integer(256); + Object d = new Integer(256); Object e = 111.1f; Assert.assertTrue(AssistKit.equals(a, b)); Assert.assertTrue(AssistKit.equals(null, null)); Assert.assertFalse(AssistKit.equals(null, a)); - - //c 和 d应该不是同一个对象啊?为什么返回True? - //Assert.assertTrue(AssistKit.equals(c, d)); Assert.assertFalse(AssistKit.equals(a,e)); } @@ -68,12 +64,5 @@ public class AssistKitTest { Object[] a = new Object[]{s}; Assert.assertEquals(Arrays.hashCode(a), AssistKit.hashCode(s)); Assert.assertEquals(0, AssistKit.hashCode(null)); - } - -// 暂时还没有用到,先不写单元测试 -// @Test -// public void toString1() { -// -// } } \ No newline at end of file From 6bc3ee0f919d3bc8066be4359314c87033e1c7ac Mon Sep 17 00:00:00 2001 From: zack Date: Mon, 26 Aug 2019 19:20:36 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E6=94=B9?= =?UTF-8?q?=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/cal/CalculatorKit.java | 1 - src/main/java/com/fanruan/api/function/FunctionKit.java | 7 +++---- src/main/java/com/fanruan/api/report/TemplateKit.java | 7 +++---- src/main/java/com/fanruan/api/report/analy/AnalyKit.java | 7 +++---- src/main/java/com/fanruan/api/util/TransmissionKit.java | 8 ++++---- src/test/java/com/fanruan/api/ModulePrepare.java | 7 +++---- .../java/com/fanruan/api/cal/CalculatorKitEnvTest.java | 7 +++---- src/test/java/com/fanruan/api/cal/CalculatorKitTest.java | 7 +++---- .../java/com/fanruan/api/function/FunctionKitTest.java | 7 +++---- .../java/com/fanruan/api/util/TransmissionKitTest.java | 7 +++---- 10 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/fanruan/api/cal/CalculatorKit.java b/src/main/java/com/fanruan/api/cal/CalculatorKit.java index 1874e59..0e47557 100644 --- a/src/main/java/com/fanruan/api/cal/CalculatorKit.java +++ b/src/main/java/com/fanruan/api/cal/CalculatorKit.java @@ -19,7 +19,6 @@ import com.fr.web.session.SessionIDInfo; import java.util.Map; /** - * @ClassName CalculatorKit * @Author zack * @Date 2019/8/23 * @Version 10.0 diff --git a/src/main/java/com/fanruan/api/function/FunctionKit.java b/src/main/java/com/fanruan/api/function/FunctionKit.java index c44ce3f..3784174 100644 --- a/src/main/java/com/fanruan/api/function/FunctionKit.java +++ b/src/main/java/com/fanruan/api/function/FunctionKit.java @@ -10,10 +10,9 @@ import java.util.ArrayList; import java.util.List; /** - * @ClassName FunctionKit - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 * 函数相关工具类 */ public class FunctionKit { diff --git a/src/main/java/com/fanruan/api/report/TemplateKit.java b/src/main/java/com/fanruan/api/report/TemplateKit.java index af520eb..f2282df 100644 --- a/src/main/java/com/fanruan/api/report/TemplateKit.java +++ b/src/main/java/com/fanruan/api/report/TemplateKit.java @@ -3,10 +3,9 @@ package com.fanruan.api.report; import com.fr.io.TemplateWorkBookIO; import com.fr.main.TemplateWorkBook; /** - * @ClassName TemplateKit - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 * 模板操作相关工具类 */ public class TemplateKit { diff --git a/src/main/java/com/fanruan/api/report/analy/AnalyKit.java b/src/main/java/com/fanruan/api/report/analy/AnalyKit.java index 266b375..0deba55 100644 --- a/src/main/java/com/fanruan/api/report/analy/AnalyKit.java +++ b/src/main/java/com/fanruan/api/report/analy/AnalyKit.java @@ -21,10 +21,9 @@ import java.util.Iterator; import java.util.Map; /** - * @ClassName AnalyKit - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 * 数据分析相关工具类 */ public class AnalyKit { diff --git a/src/main/java/com/fanruan/api/util/TransmissionKit.java b/src/main/java/com/fanruan/api/util/TransmissionKit.java index 6a310f0..afd0ea4 100644 --- a/src/main/java/com/fanruan/api/util/TransmissionKit.java +++ b/src/main/java/com/fanruan/api/util/TransmissionKit.java @@ -6,11 +6,11 @@ import com.fr.base.EmailManager; import com.fr.base.sms.SMSManager; /** - * @ClassName TransmissionKit - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 * fine kit for data transmission.(eg. email or sms...) + * 数据发送工具类(比如:邮件发送,短信发送) */ public class TransmissionKit { /** diff --git a/src/test/java/com/fanruan/api/ModulePrepare.java b/src/test/java/com/fanruan/api/ModulePrepare.java index 96d63fa..619513c 100644 --- a/src/test/java/com/fanruan/api/ModulePrepare.java +++ b/src/test/java/com/fanruan/api/ModulePrepare.java @@ -18,10 +18,9 @@ import org.junit.After; import org.junit.Before; /** - * @ClassName ModulePrepare - * @Author zack - * @Date 2019/8/26 - * @Version 10.0 + * @author zack + * @date 2019/8/26 + * @version 10.0 */ public class ModulePrepare { Module module = null; diff --git a/src/test/java/com/fanruan/api/cal/CalculatorKitEnvTest.java b/src/test/java/com/fanruan/api/cal/CalculatorKitEnvTest.java index 0b56fd2..9f228c8 100644 --- a/src/test/java/com/fanruan/api/cal/CalculatorKitEnvTest.java +++ b/src/test/java/com/fanruan/api/cal/CalculatorKitEnvTest.java @@ -19,10 +19,9 @@ import java.util.Map; /** * 需要启动模块的算子单元测试 * - * @ClassName CalculatorKitEnvTest - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 */ public class CalculatorKitEnvTest extends Prepare { @Test diff --git a/src/test/java/com/fanruan/api/cal/CalculatorKitTest.java b/src/test/java/com/fanruan/api/cal/CalculatorKitTest.java index 595964c..fc6fe62 100644 --- a/src/test/java/com/fanruan/api/cal/CalculatorKitTest.java +++ b/src/test/java/com/fanruan/api/cal/CalculatorKitTest.java @@ -9,10 +9,9 @@ import java.util.HashMap; import java.util.Map; /** - * @ClassName CalculatorKitTest - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 */ public class CalculatorKitTest { @Test diff --git a/src/test/java/com/fanruan/api/function/FunctionKitTest.java b/src/test/java/com/fanruan/api/function/FunctionKitTest.java index 515d81b..db3f0f9 100644 --- a/src/test/java/com/fanruan/api/function/FunctionKitTest.java +++ b/src/test/java/com/fanruan/api/function/FunctionKitTest.java @@ -10,10 +10,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; /** - * @ClassName FunctionKitTest - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 */ public class FunctionKitTest extends Prepare { diff --git a/src/test/java/com/fanruan/api/util/TransmissionKitTest.java b/src/test/java/com/fanruan/api/util/TransmissionKitTest.java index b0e0c24..15da05a 100644 --- a/src/test/java/com/fanruan/api/util/TransmissionKitTest.java +++ b/src/test/java/com/fanruan/api/util/TransmissionKitTest.java @@ -8,10 +8,9 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** - * @ClassName TransmissionKitTest - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 */ public class TransmissionKitTest { @Test From 46bf65f147e233f8d54e569d84c103f68214c79a Mon Sep 17 00:00:00 2001 From: zack Date: Mon, 26 Aug 2019 19:21:42 +0800 Subject: [PATCH 5/9] rt --- src/main/java/com/fanruan/api/cal/CalculatorKit.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/fanruan/api/cal/CalculatorKit.java b/src/main/java/com/fanruan/api/cal/CalculatorKit.java index 0e47557..4a370e5 100644 --- a/src/main/java/com/fanruan/api/cal/CalculatorKit.java +++ b/src/main/java/com/fanruan/api/cal/CalculatorKit.java @@ -19,9 +19,9 @@ import com.fr.web.session.SessionIDInfo; import java.util.Map; /** - * @Author zack - * @Date 2019/8/23 - * @Version 10.0 + * @author zack + * @date 2019/8/23 + * @version 10.0 * 帆软算子工具类(主要用于公式计算) */ public class CalculatorKit { From 0d7f2c59e57d6ae6d26eb4ab1a2b33e8916ef4e5 Mon Sep 17 00:00:00 2001 From: Kalven Date: Tue, 27 Aug 2019 09:55:43 +0800 Subject: [PATCH 6/9] =?UTF-8?q?KERNEL-1117=20=E6=94=B9=E5=8F=98=E4=BA=86ba?= =?UTF-8?q?sekit=E5=92=8CGUICoreKit=E7=9A=84=E4=BD=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BA=86=E4=B9=8B=E5=89=8D=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/design/util/GUICoreKit.java | 24 +++++++++++++++++++ .../java/com/fanruan/api/util/ArrayKit.java | 10 ++++++++ .../java/com/fanruan/api/util/GeneralKit.java | 15 ++++++++++++ .../java/com/fanruan/api/util/StableKit.java | 16 +++++++++++++ .../com/fanruan/api/util/TemplateKit.java | 19 +++++++++++++++ .../com/fanruan/api/util/GeneralKitTest.java | 15 +++++++++++- .../com/fanruan/api/util/StableKitTest.java | 14 +++++++++++ 7 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/fanruan/api/design/util/GUICoreKit.java create mode 100644 src/main/java/com/fanruan/api/util/StableKit.java create mode 100644 src/main/java/com/fanruan/api/util/TemplateKit.java create mode 100644 src/test/java/com/fanruan/api/util/StableKitTest.java diff --git a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java new file mode 100644 index 0000000..8a99ddf --- /dev/null +++ b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java @@ -0,0 +1,24 @@ +package com.fanruan.api.design.util; + +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; + +public class GUICoreKit { + + public static JPanel createFlowPane(Object... var0) { + return GUICoreUtils.createFlowPane(var0); + } + + /** + * 弹出菜单,在坐标为x,y处弹出内容为component的菜单 + * @param menu + * @param component + * @param x + * @param y + */ + public static void showPopupMenu(JPopupMenu menu, Component component, int x, int y) { + GUICoreUtils.showPopupMenu(menu, component, x, y); + } +} diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index 2a3d1b2..3eb9b75 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -82,4 +82,14 @@ public class ArrayKit { * @return 返回增加元素后的数组 */ public static T[] addAll(T[] array, T... element){return ArrayUtils.addAll(array, element);}; + + /** + * 判断数组是否为不空 + * @param array + * @param + * @return 若数组array不空返回true,否则返回false + */ + public static boolean isNotEmpty(T[] array) { + return ArrayUtils.isNotEmpty(array); + } } diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index f5e328e..2b470b7 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -1,5 +1,6 @@ package com.fanruan.api.util; +import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,7 +51,21 @@ public class GeneralKit { return GeneralUtils.objectToNumber(obj, returnNull); } + /** + * 读取jar的版本号 + * @return 返回jar版本号 + */ public static @Nullable String readBuildNO() { return GeneralUtils.readBuildNO(); } + + /** + * 返回两个对象比较的大小 + * @param obj1 + * @param obj2 + * @return 若相等返回0,obj1小于obj2返回负数,否则返回正数 + */ + public static int compare(Object obj1, Object obj2) { + return ComparatorUtils.compare(obj1, obj2); + } } diff --git a/src/main/java/com/fanruan/api/util/StableKit.java b/src/main/java/com/fanruan/api/util/StableKit.java new file mode 100644 index 0000000..112339e --- /dev/null +++ b/src/main/java/com/fanruan/api/util/StableKit.java @@ -0,0 +1,16 @@ +package com.fanruan.api.util; + +import com.fr.stable.StableUtils; + +public class StableKit { + + /** + * 判断class1是否是class2的子类实例化 + * @param class1 + * @param class2 + * @return 返回判断结果 + */ + public static boolean classInstanceOf(Class class1, Class class2) { + return StableUtils.classInstanceOf(class1, class2); + } +} diff --git a/src/main/java/com/fanruan/api/util/TemplateKit.java b/src/main/java/com/fanruan/api/util/TemplateKit.java new file mode 100644 index 0000000..e8704fe --- /dev/null +++ b/src/main/java/com/fanruan/api/util/TemplateKit.java @@ -0,0 +1,19 @@ +package com.fanruan.api.util; + +import com.fr.base.TemplateUtils; + +import java.util.Map; + +public class TemplateKit { + + /** + * 根据参数, 来计算文档字符串 + * @param tpl + * @param map + * @return 返回计算后的值 + * @throws Exception + */ + public static String renderParameter4Tpl(String tpl, Map map) throws Exception { + return TemplateUtils.renderParameter4Tpl(tpl, map); + } +} diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 84b8e23..1383740 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -1,6 +1,8 @@ package com.fanruan.api.util; import com.fanruan.api.Prepare; +import com.fr.general.GeneralUtils; +import com.fr.third.javax.persistence.criteria.CriteriaBuilder; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,18 @@ public class GeneralKitTest extends Prepare { @Test public void readBuildNO() { - Assert.assertEquals(GeneralKit.readBuildNO(), com.fr.general.GeneralUtils.readBuildNO()); + Assert.assertEquals(GeneralKit.readBuildNO(), GeneralUtils.readBuildNO()); } + + @Test + public void compare() { + Integer s = new Integer(1); + Integer s3 = new Integer(1); + Integer s1 = new Integer(2); + Integer s2 = new Integer(0); + Assert.assertEquals(GeneralKit.compare(s,s1),-1); + Assert.assertEquals(GeneralKit.compare(s,s3),0); + Assert.assertEquals(GeneralKit.compare(s,s2),1); + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/StableKitTest.java b/src/test/java/com/fanruan/api/util/StableKitTest.java new file mode 100644 index 0000000..cb470b7 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/StableKitTest.java @@ -0,0 +1,14 @@ +package com.fanruan.api.util; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class StableKitTest { + + @Test + public void classInstanceOf() { + assertEquals(StableKit.classInstanceOf(Integer.class,Object.class),true); + assertEquals(StableKit.classInstanceOf(Object.class,Integer.class),false); + } +} \ No newline at end of file From 4223f6f0bbfdad77dc0f4975072e04da49db7afa Mon Sep 17 00:00:00 2001 From: Kalven Date: Tue, 27 Aug 2019 10:00:58 +0800 Subject: [PATCH 7/9] =?UTF-8?q?KERNEL-1117=20=E5=88=A0=E9=99=A4BaseKit?= =?UTF-8?q?=E5=92=8CGUICoreKit=EF=BC=8CBaseKit=E5=86=85=E5=AE=B9=E5=9C=A8I?= =?UTF-8?q?OKit=E4=B8=AD=E5=AE=9E=E7=8E=B0=EF=BC=8CGUICoreKit=E6=8D=A2?= =?UTF-8?q?=E4=BA=86=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/util/BaseKit.java | 26 ------------------- .../java/com/fanruan/api/util/GUICoreKit.java | 24 ----------------- 2 files changed, 50 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/util/BaseKit.java delete mode 100644 src/main/java/com/fanruan/api/util/GUICoreKit.java diff --git a/src/main/java/com/fanruan/api/util/BaseKit.java b/src/main/java/com/fanruan/api/util/BaseKit.java deleted file mode 100644 index 7206d1f..0000000 --- a/src/main/java/com/fanruan/api/util/BaseKit.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.base.BaseUtils; - -import javax.swing.*; -import java.io.InputStream; - -public class BaseKit { - /** - * 从file中读数据,以流的形式读出数据 - * @param file - * @return 返回file文件,文件数据流 - */ - public static InputStream readResource(String file) { - return BaseUtils.readResource(file); - } - - /** - * 从file中读取数据,根据数据返回Icon图片 - * @param file - * @return 返回Icon图片 - */ - public static Icon readIcon(String file) { - return BaseUtils.readIcon(file); - } -} diff --git a/src/main/java/com/fanruan/api/util/GUICoreKit.java b/src/main/java/com/fanruan/api/util/GUICoreKit.java deleted file mode 100644 index 4914cfc..0000000 --- a/src/main/java/com/fanruan/api/util/GUICoreKit.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.design.utils.gui.GUICoreUtils; - -import javax.swing.*; -import java.awt.*; - -public class GUICoreKit { - - public static JPanel createFlowPane(Object... var0) { - return GUICoreUtils.createFlowPane(var0); - } - - /** - * 弹出菜单,在坐标为x,y处弹出内容为component的菜单 - * @param menu - * @param component - * @param x - * @param y - */ - public static void showPopupMenu(JPopupMenu menu, Component component, int x, int y) { - GUICoreUtils.showPopupMenu(menu, component, x, y); - } -} From 4513d48372de566db3e8ad55cbd09cb0fc61f41d Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 27 Aug 2019 13:56:12 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E7=AC=A6?= =?UTF-8?q?=E5=90=88=E8=A7=84=E8=8C=83=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 +++++ .../java/com/fanruan/api/util/ReflectKit.java | 16 +++++++++++ .../java/com/fanruan/api/util/RenderKit.java | 22 +++++++++++++++ .../java/com/fanruan/api/util/StableKit.java | 16 ----------- .../com/fanruan/api/util/TemplateKit.java | 19 ------------- .../com/fanruan/api/util/ReflectKitTest.java | 14 ++++++++++ .../com/fanruan/api/util/RenderKitTest.java | 28 +++++++++++++++++++ .../com/fanruan/api/util/StableKitTest.java | 14 ---------- 8 files changed, 87 insertions(+), 49 deletions(-) create mode 100644 src/main/java/com/fanruan/api/util/ReflectKit.java create mode 100644 src/main/java/com/fanruan/api/util/RenderKit.java delete mode 100644 src/main/java/com/fanruan/api/util/StableKit.java delete mode 100644 src/main/java/com/fanruan/api/util/TemplateKit.java create mode 100644 src/test/java/com/fanruan/api/util/ReflectKitTest.java create mode 100644 src/test/java/com/fanruan/api/util/RenderKitTest.java delete mode 100644 src/test/java/com/fanruan/api/util/StableKitTest.java diff --git a/pom.xml b/pom.xml index d90e077..4737dfd 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,13 @@ ${common-version} compile + + + com.fr.report + fine-report-designer + ${common-version} + compile + junit junit diff --git a/src/main/java/com/fanruan/api/util/ReflectKit.java b/src/main/java/com/fanruan/api/util/ReflectKit.java new file mode 100644 index 0000000..ef9d4b9 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/ReflectKit.java @@ -0,0 +1,16 @@ +package com.fanruan.api.util; + +import com.fr.stable.StableUtils; + +public class ReflectKit { + + /** + * 判断一个类是否是另一个类的子类 + * @param current 当前类 + * @param target 目标类 + * @return 如果当前类是目标类的子类,则返回true,否则返回false + */ + public static boolean classInstanceOf(Class current, Class target) { + return StableUtils.classInstanceOf(current, target); + } +} diff --git a/src/main/java/com/fanruan/api/util/RenderKit.java b/src/main/java/com/fanruan/api/util/RenderKit.java new file mode 100644 index 0000000..3858679 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/RenderKit.java @@ -0,0 +1,22 @@ +package com.fanruan.api.util; + +import com.fr.base.TemplateUtils; + +import java.util.Map; + +/** + * 文本动态渲染工具类 + */ +public class RenderKit { + + /** + * 根据参数, 来计算文档字符串 + * @param text 待渲染的文本模板 + * @param map 参数集合 + * @return 返回渲染后的文本 + * @throws Exception 渲染过程中出现错误则抛出此异常 + */ + public static String renderParameter4Tpl(String text, Map map) throws Exception { + return TemplateUtils.renderParameter4Tpl(text, map); + } +} diff --git a/src/main/java/com/fanruan/api/util/StableKit.java b/src/main/java/com/fanruan/api/util/StableKit.java deleted file mode 100644 index 112339e..0000000 --- a/src/main/java/com/fanruan/api/util/StableKit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.stable.StableUtils; - -public class StableKit { - - /** - * 判断class1是否是class2的子类实例化 - * @param class1 - * @param class2 - * @return 返回判断结果 - */ - public static boolean classInstanceOf(Class class1, Class class2) { - return StableUtils.classInstanceOf(class1, class2); - } -} diff --git a/src/main/java/com/fanruan/api/util/TemplateKit.java b/src/main/java/com/fanruan/api/util/TemplateKit.java deleted file mode 100644 index e8704fe..0000000 --- a/src/main/java/com/fanruan/api/util/TemplateKit.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.base.TemplateUtils; - -import java.util.Map; - -public class TemplateKit { - - /** - * 根据参数, 来计算文档字符串 - * @param tpl - * @param map - * @return 返回计算后的值 - * @throws Exception - */ - public static String renderParameter4Tpl(String tpl, Map map) throws Exception { - return TemplateUtils.renderParameter4Tpl(tpl, map); - } -} diff --git a/src/test/java/com/fanruan/api/util/ReflectKitTest.java b/src/test/java/com/fanruan/api/util/ReflectKitTest.java new file mode 100644 index 0000000..1c88dfb --- /dev/null +++ b/src/test/java/com/fanruan/api/util/ReflectKitTest.java @@ -0,0 +1,14 @@ +package com.fanruan.api.util; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ReflectKitTest { + + @Test + public void classInstanceOf() { + assertEquals(ReflectKit.classInstanceOf(Integer.class,Object.class),true); + assertEquals(ReflectKit.classInstanceOf(Object.class,Integer.class),false); + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/RenderKitTest.java b/src/test/java/com/fanruan/api/util/RenderKitTest.java new file mode 100644 index 0000000..4c53c41 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/RenderKitTest.java @@ -0,0 +1,28 @@ +package com.fanruan.api.util; + +import com.fanruan.api.Prepare; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-27 + */ +public class RenderKitTest extends Prepare { + + @Test + public void renderParameter4Tpl() throws Exception { + Map map = new HashMap<>(); + map.put("age", 20); + map.put("name", "Alex"); + map.put("salary", 100); + String text = "${name} is ${age} years old, he earned ${salary} dollars per month."; + Assert.assertEquals("Alex is 20 years old, he earned 100 dollars per month.", RenderKit.renderParameter4Tpl(text, map)); + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/StableKitTest.java b/src/test/java/com/fanruan/api/util/StableKitTest.java deleted file mode 100644 index cb470b7..0000000 --- a/src/test/java/com/fanruan/api/util/StableKitTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fanruan.api.util; - -import org.junit.Test; - -import static org.junit.Assert.*; - -public class StableKitTest { - - @Test - public void classInstanceOf() { - assertEquals(StableKit.classInstanceOf(Integer.class,Object.class),true); - assertEquals(StableKit.classInstanceOf(Object.class,Integer.class),false); - } -} \ No newline at end of file From 0cee7eb4478fa1a7684cc66e3a4d0f3dc4626d4e Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 27 Aug 2019 13:57:55 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E7=AC=A6?= =?UTF-8?q?=E5=90=88=E8=A7=84=E8=8C=83=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/util/ArrayKitTest.java | 107 +++++++++--------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/src/test/java/com/fanruan/api/util/ArrayKitTest.java b/src/test/java/com/fanruan/api/util/ArrayKitTest.java index d63d080..cfedded 100644 --- a/src/test/java/com/fanruan/api/util/ArrayKitTest.java +++ b/src/test/java/com/fanruan/api/util/ArrayKitTest.java @@ -1,6 +1,5 @@ package com.fanruan.api.util; -import com.fr.general.Inter; -import com.fr.stable.ArrayUtils; + import com.fanruan.api.Prepare; import org.junit.Assert; import org.junit.Test; @@ -8,31 +7,31 @@ import org.junit.Test; public class ArrayKitTest extends Prepare { @Test public void isEmpty() throws Exception{ - Object emptyArray []=new Object[0]; - Object notEmptyArray [] = new Object[1]; - Assert.assertEquals(ArrayKit.isEmpty(emptyArray), true); - Assert.assertEquals(ArrayKit.isEmpty(notEmptyArray), false); + Object[] emptyArray = new Object[0]; + Object[] notEmptyArray = new Object[1]; + Assert.assertTrue(ArrayKit.isEmpty(emptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(notEmptyArray)); } @Test public void remove() throws Exception{ - Integer intTestArray [] = {1,2,3,4}; - Integer intTestResult [] = {1,2,3}; - Boolean booleanTestArray [] = {true, true, true, false}; - Boolean booleanTestResult [] = {true, true, true}; - Byte byteTestArray [] = {100,101,102,103}; - Byte byteTestResult [] = {100,101,102}; - Character charTestArray [] = {'a','b','c','d'}; - Character charTestResult [] = {'a','b','c'}; - Double doubleTestArray [] = {1.1,2.2,3.3,4.4}; - Double doubleTestResult [] = {1.1,2.2,3.3}; - Float floatTestArray [] = {1.1f,2.2f,3.3f,4.4f}; - Float floatTestResult [] = {1.1f,2.2f,3.3f}; - Long longTestArray [] = {1L,2L,3L,4L}; - Long longTestResult [] = {1L,2L,3L}; - Short shortTestArray [] = {1,2,3,4}; - Short shortTestResult [] = {1,2,3}; + Integer[] intTestArray = {1, 2, 3, 4}; + Integer[] intTestResult = {1, 2, 3}; + Boolean[] booleanTestArray = {true, true, true, false}; + Boolean[] booleanTestResult = {true, true, true}; + Byte[] byteTestArray = {100, 101, 102, 103}; + Byte[] byteTestResult = {100, 101, 102}; + Character[] charTestArray = {'a', 'b', 'c', 'd'}; + Character[] charTestResult = {'a', 'b', 'c'}; + Double[] doubleTestArray = {1.1, 2.2, 3.3, 4.4}; + Double[] doubleTestResult = {1.1, 2.2, 3.3}; + Float[] floatTestArray = {1.1f, 2.2f, 3.3f, 4.4f}; + Float[] floatTestResult = {1.1f, 2.2f, 3.3f}; + Long[] longTestArray = {1L, 2L, 3L, 4L}; + Long[] longTestResult = {1L, 2L, 3L}; + Short[] shortTestArray = {1, 2, 3, 4}; + Short[] shortTestResult = {1, 2, 3}; Assert.assertEquals(ArrayKit.remove(intTestArray, 3), intTestResult); Assert.assertEquals(ArrayKit.remove(booleanTestArray, 3), booleanTestResult); Assert.assertEquals(ArrayKit.remove(byteTestArray, 3), byteTestResult); @@ -45,22 +44,22 @@ public class ArrayKitTest extends Prepare { @Test public void add() throws Exception{ - Integer intTestArray [] = {1,2,3,4}; - Integer intTestResult [] = {1,2,3,4,5}; - Boolean booleanTestArray [] = {true, true, true, false}; - Boolean booleanTestResult [] = {true, true, true, false, true}; - Byte byteTestArray [] = {1}; - Byte byteTestResult [] = {1,0}; - Character charTestArray [] = {'a','b','c','d'}; - Character charTestResult [] = {'a','b','c','d','e'}; - Double doubleTestArray [] = {1.1,2.2,3.3,4.4}; - Double doubleTestResult [] = {1.1,2.2,3.3,4.4,5.5}; - Float floatTestArray [] = {1.1f,2.2f,3.3f,4.4f}; - Float floatTestResult [] = {1.1f,2.2f,3.3f,4.4f,5.5f}; - Long longTestArray [] = {1L,2L,3L,4L}; - Long longTestResult [] = {1L,2L,3L,4L,5L}; - Short shortTestArray [] = {1,2,3,4}; - Short shortTestResult [] = {1,2,3,4,5}; + Integer[] intTestArray = {1, 2, 3, 4}; + Integer[] intTestResult = {1, 2, 3, 4, 5}; + Boolean[] booleanTestArray = {true, true, true, false}; + Boolean[] booleanTestResult = {true, true, true, false, true}; + Byte[] byteTestArray = {1}; + Byte[] byteTestResult = {1, 0}; + Character[] charTestArray = {'a', 'b', 'c', 'd'}; + Character[] charTestResult = {'a', 'b', 'c', 'd', 'e'}; + Double[] doubleTestArray = {1.1, 2.2, 3.3, 4.4}; + Double[] doubleTestResult = {1.1, 2.2, 3.3, 4.4, 5.5}; + Float[] floatTestArray = {1.1f, 2.2f, 3.3f, 4.4f}; + Float[] floatTestResult = {1.1f, 2.2f, 3.3f, 4.4f, 5.5f}; + Long[] longTestArray = {1L, 2L, 3L, 4L}; + Long[] longTestResult = {1L, 2L, 3L, 4L, 5L}; + Short[] shortTestArray = {1, 2, 3, 4}; + Short[] shortTestResult = {1, 2, 3, 4, 5}; Assert.assertEquals(ArrayKit.add(intTestArray, 5), intTestResult); Assert.assertEquals(ArrayKit.add(booleanTestArray, true), booleanTestResult); Assert.assertEquals(ArrayKit.add(byteTestArray, new Byte("0")), byteTestResult); @@ -73,22 +72,22 @@ public class ArrayKitTest extends Prepare { @Test public void addAll() throws Exception{ - Integer intTestArray [] = {1,2,3,4}; - Integer intTestResult [] = {1,2,3,4,5,6}; - Boolean booleanTestArray [] = {true, true, true, false}; - Boolean booleanTestResult [] = {true, true, true, false, true,true}; - Byte byteTestArray [] = {1}; - Byte byteTestResult [] = {1,0,0}; - Character charTestArray [] = {'a','b','c','d'}; - Character charTestResult [] = {'a','b','c','d','e','f'}; - Double doubleTestArray [] = {1.1,2.2,3.3,4.4}; - Double doubleTestResult [] = {1.1,2.2,3.3,4.4,5.5,6.6}; - Float floatTestArray [] = {1.1f,2.2f,3.3f,4.4f}; - Float floatTestResult [] = {1.1f,2.2f,3.3f,4.4f,5.5f,6.6f}; - Long longTestArray [] = {1L,2L,3L,4L}; - Long longTestResult [] = {1L,2L,3L,4L,5L,6L}; - Short shortTestArray [] = {1,2,3,4}; - Short shortTestResult [] = {1,2,3,4,5,6}; + Integer[] intTestArray = {1, 2, 3, 4}; + Integer[] intTestResult = {1, 2, 3, 4, 5, 6}; + Boolean[] booleanTestArray = {true, true, true, false}; + Boolean[] booleanTestResult = {true, true, true, false, true, true}; + Byte[] byteTestArray = {1}; + Byte[] byteTestResult = {1, 0, 0}; + Character[] charTestArray = {'a', 'b', 'c', 'd'}; + Character[] charTestResult = {'a', 'b', 'c', 'd', 'e', 'f'}; + Double[] doubleTestArray = {1.1, 2.2, 3.3, 4.4}; + Double[] doubleTestResult = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6}; + Float[] floatTestArray = {1.1f, 2.2f, 3.3f, 4.4f}; + Float[] floatTestResult = {1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f}; + Long[] longTestArray = {1L, 2L, 3L, 4L}; + Long[] longTestResult = {1L, 2L, 3L, 4L, 5L, 6L}; + Short[] shortTestArray = {1, 2, 3, 4}; + Short[] shortTestResult = {1, 2, 3, 4, 5, 6}; Assert.assertEquals(ArrayKit.addAll(intTestArray, 5,6), intTestResult); Assert.assertEquals(ArrayKit.addAll(booleanTestArray, true, true), booleanTestResult); Assert.assertEquals(ArrayKit.addAll(byteTestArray, new Byte("0"), new Byte("0")), byteTestResult);