Browse Source

update: 新增数组方法和参数方法并提供单测。

pull/19/head
zjz1993 5 years ago
parent
commit
05c42fc0a3
  1. 9
      src/main/java/com/fanruan/api/cal/ParameterKit.java
  2. 17
      src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java
  3. 11
      src/main/java/com/fanruan/api/util/ArrayKit.java
  4. 13
      src/test/java/com/fanruan/api/cal/ParameterKitTest.java
  5. 14
      src/test/java/com/fanruan/api/util/ArrayKitTest.java

9
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);
}
}

17
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;

11
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 <T> boolean isNotEmpty(T[] array) {
return ArrayUtils.isNotEmpty(array);
}
/**
* 返回一个ArrayList
* @param array 数组
* @return 链表
* */
public static <T> List<T> toList(T[] array) {
return ArrayUtils.toList(array);
}
}

13
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);
}
}

14
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<Integer> result = new ArrayList<Integer>();
result.add(1);
result.add(2);
result.add(3);
Assert.assertEquals(ArrayKit.toList(array),result);
}
}

Loading…
Cancel
Save