From efbe7a04604548a94b2435e35b2c63914a51ba3b Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 4 Sep 2019 11:41:51 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9Eequals=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=8F=8A=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/util/GeneralKit.java | 13 +++++++++- .../com/fanruan/api/util/GeneralKitTest.java | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index 9e13593..8c3e3f6 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -4,6 +4,7 @@ import com.fr.base.FRContext; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.stable.CommonUtils; +import com.fr.stable.StringUtils; import com.fr.third.guava.base.Objects; import com.fr.stable.StableUtils; import org.jetbrains.annotations.NotNull; @@ -83,7 +84,7 @@ public class GeneralKit { public static String join(Object[] array, String se) { return StableUtils.join(array, se); } - /* + /** * 返回国际化区属 * @return 国际化后区域属性 */ @@ -91,4 +92,14 @@ public class GeneralKit { public static Locale getLocale() { return FRContext.getLocale(); } + + /** + * 检测两个数组是否相等 + * @param array1 数组1 + * @param array2 数组2 + * @return 判断的结果 + * */ + public static boolean equals(T[] array1, T[] array2){ + return ComparatorUtils.equals(array1, array2); + } } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index c8057ec..0d4e275 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -52,4 +52,28 @@ public class GeneralKitTest extends Prepare { public void getLocale() { Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); } + @Test + public void equals(){ + Object objArray[] = {1,2,3}; + Integer intArray[] = {1,2,3}; + Long[] longArray = {1L,2L,3L}; + Double doubleArray[] = {1.1,2.2,3.3}; + Byte[] byteArray = {1,2,3}; + Character[] charArray = {'a', 'b', 'c'}; + Boolean booleanArray[] = {true,true,false}; + Assert.assertEquals(GeneralKit.equals(objArray, new Object[]{1,2,3}), true); + Assert.assertEquals(GeneralKit.equals(objArray, new Object[]{1,2,3,4}), false); + Assert.assertEquals(GeneralKit.equals(intArray, new Integer[]{1,2,3}), true); + Assert.assertEquals(GeneralKit.equals(intArray, new Integer[]{1,2,3,4}), false); + Assert.assertEquals(GeneralKit.equals(longArray, new Long[]{1L,2L,3L}), true); + Assert.assertEquals(GeneralKit.equals(longArray, new Long[]{1L,2L,3L,4L}), false); + Assert.assertEquals(GeneralKit.equals(doubleArray, new Double[]{1.1,2.2,3.3}), true); + Assert.assertEquals(GeneralKit.equals(doubleArray, new Double[]{1.1,2.2,3.3,4.4}), false); + Assert.assertEquals(GeneralKit.equals(byteArray, new Byte[]{1,2,3}), true); + Assert.assertEquals(GeneralKit.equals(byteArray, new Byte[]{1,2,3,4}), false); + Assert.assertEquals(GeneralKit.equals(charArray, new Character[]{'a','b','c'}), true); + Assert.assertEquals(GeneralKit.equals(charArray, new Character[]{'a','b','c','d'}), false); + Assert.assertEquals(GeneralKit.equals(booleanArray, new Boolean[]{true,true,false}), true); + Assert.assertEquals(GeneralKit.equals(booleanArray, new Boolean[]{true,true,false,false}), false); + } } \ No newline at end of file