From 05c42fc0a37521f8c7deb461a5477b671645c853 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Tue, 3 Sep 2019 17:44:36 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=92=8C=E5=8F=82=E6=95=B0=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BE=9B=E5=8D=95=E6=B5=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/ParameterKit.java | 9 +++++++++ .../api/design/ui/editor/ValueEditors.java | 17 +---------------- .../java/com/fanruan/api/util/ArrayKit.java | 11 +++++++++++ .../com/fanruan/api/cal/ParameterKitTest.java | 13 +++++++++++++ .../java/com/fanruan/api/util/ArrayKitTest.java | 14 ++++++++++++++ 5 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index bc1cb30..67e316e 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -108,4 +108,13 @@ public class ParameterKit { public static ParameterProvider[] analyzeAndUnionSameParameters(String[] paramTexts, Parameter[] ps){ return ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps); } + + /** + * 将ParameterProvider类型数组转换为Parameter类型数组 + * @param providers ParameterProvider类型数组 + * @return Parameter类型数组 + * */ + public static Parameter[] providers2Parameter(ParameterProvider[] providers) { + return Parameter.providers2Parameter(providers); + } } diff --git a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java index 4dda75f..760464c 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java +++ b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java @@ -4,22 +4,7 @@ import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.ui.component.table.model.ParameterTableModel; import com.fanruan.api.util.StringKit; import com.fr.base.BaseFormula; -import com.fr.design.editor.editor.BooleanEditor; -import com.fr.design.editor.editor.ColumnRowEditor; -import com.fr.design.editor.editor.ColumnRowGroupEditor; -import com.fr.design.editor.editor.ColumnSelectedEditor; -import com.fr.design.editor.editor.ConstantsEditor; -import com.fr.design.editor.editor.CursorEditor; -import com.fr.design.editor.editor.DateEditor; -import com.fr.design.editor.editor.DoubleEditor; -import com.fr.design.editor.editor.Editor; -import com.fr.design.editor.editor.FormulaEditor; -import com.fr.design.editor.editor.IntegerEditor; -import com.fr.design.editor.editor.NoneEditor; -import com.fr.design.editor.editor.ParameterEditor; -import com.fr.design.editor.editor.SpinnerIntegerEditor; -import com.fr.design.editor.editor.TextEditor; -import com.fr.design.editor.editor.WidgetNameEditor; +import com.fr.design.editor.editor.*; import java.util.ArrayList; import java.util.Iterator; diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index 56322f1..92510c4 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -2,6 +2,8 @@ package com.fanruan.api.util; import com.fr.stable.ArrayUtils; +import java.util.List; + /** * @author richie * @version 10.0 @@ -91,4 +93,13 @@ public class ArrayKit { public static boolean isNotEmpty(T[] array) { return ArrayUtils.isNotEmpty(array); } + + /** + * 返回一个ArrayList + * @param array 数组 + * @return 链表 + * */ + public static List toList(T[] array) { + return ArrayUtils.toList(array); + } } diff --git a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java index 4093687..2b05a31 100644 --- a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java +++ b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java @@ -114,4 +114,17 @@ public class ParameterKitTest extends Prepare { Assert.assertEquals(provider.getName(),"p1"); Assert.assertEquals("", provider.getValue()); } + + @Test + public void providers2Parameter() { + ParameterProvider[] parameters = new ParameterProvider[]{ + ParameterKit.newParameter("p1", 100), + ParameterKit.newParameter("p2", 200) + }; + Parameter [] result = new Parameter[]{ + new Parameter("p1", 100), + new Parameter("p2", 200) + }; + Assert.assertEquals(ParameterKit.providers2Parameter(parameters), result); + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/ArrayKitTest.java b/src/test/java/com/fanruan/api/util/ArrayKitTest.java index cfedded..054ae22 100644 --- a/src/test/java/com/fanruan/api/util/ArrayKitTest.java +++ b/src/test/java/com/fanruan/api/util/ArrayKitTest.java @@ -1,6 +1,9 @@ package com.fanruan.api.util; import com.fanruan.api.Prepare; +import java.util.*; + +import com.fr.third.org.apache.poi.hssf.record.formula.functions.Int; import org.junit.Assert; import org.junit.Test; @@ -97,4 +100,15 @@ public class ArrayKitTest extends Prepare { Assert.assertEquals(ArrayKit.addAll(longTestArray, 5L,6L), longTestResult); Assert.assertEquals(ArrayKit.addAll(shortTestArray, new Short("5"),new Short("6")), shortTestResult); } + + @Test + public void toList() throws Exception{ + Integer array[] = {1,2,3}; + ArrayList result = new ArrayList(); + result.add(1); + result.add(2); + result.add(3); + Assert.assertEquals(ArrayKit.toList(array),result); + } + }