Browse Source

feat: 改写mongodb插件时的第一次finekit补充。

master
zjz1993 5 years ago
parent
commit
906eac78e2
  1. 11
      src/main/java/com/fanruan/api/cal/ParameterKit.java
  2. 1
      src/main/java/com/fanruan/api/design/macro/UIConstants.java
  3. 11
      src/main/java/com/fanruan/api/err/JSONException.java
  4. 26
      src/main/java/com/fanruan/api/json/JSONArray.java
  5. 16
      src/main/java/com/fanruan/api/json/JSONObject.java
  6. 15
      src/main/java/com/fanruan/api/util/CodeKit.java
  7. 18
      src/main/java/com/fanruan/api/util/DateKit.java
  8. 12
      src/main/java/com/fanruan/api/util/GeneralKit.java
  9. 12
      src/test/java/com/fanruan/api/util/CodeKitTest.java
  10. 18
      src/test/java/com/fanruan/api/util/DateKitTest.java
  11. 7
      src/test/java/com/fanruan/api/util/GeneralKitTest.java

11
src/main/java/com/fanruan/api/cal/ParameterKit.java

@ -89,4 +89,15 @@ public class ParameterKit {
public static @NotNull ParameterMapNameSpace createParameterMapNameSpace(ParameterProvider[] ps) {
return ParameterMapNameSpace.create(ps);
}
/**
* 获得新的参数集合
*
* @param paramTexts sql语句
* @param ps 旧的参数集合
* @return 新参数集合
*/
public static Parameter[] analyzeAndUnionSameParameters(String[] paramTexts,
Parameter[] ps){
return ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps);
}
}

1
src/main/java/com/fanruan/api/design/macro/UIConstants.java

@ -4,5 +4,6 @@ import java.awt.*;
public class UIConstants {
Color UIPOPUPMENU_LINE_COLOR = new Color(13158861);
Color LINE_COLOR = new Color(153, 153, 153);
int ARC = 0;
}

11
src/main/java/com/fanruan/api/err/JSONException.java

@ -0,0 +1,11 @@
package com.fanruan.api.err;
public class JSONException extends com.fr.json.JSONException{
public JSONException(String var1) {
super(var1);
}
public JSONException(Throwable var1) {
super(var1);
}
}

26
src/main/java/com/fanruan/api/json/JSONArray.java

@ -0,0 +1,26 @@
package com.fanruan.api.json;
import java.util.*;
import java.lang.*;
public class JSONArray extends com.fr.json.JSONArray{
public JSONArray(){
}
public JSONArray(Collection collection){
super(collection);
}
public JSONArray(List list) {
super(list);
}
public JSONArray(Object array) {
super(array);
}
public JSONArray(String json) {
super(json);
}
}

16
src/main/java/com/fanruan/api/json/JSONObject.java

@ -0,0 +1,16 @@
package com.fanruan.api.json;
import java.util.*;
public class JSONObject extends com.fr.json.JSONObject{
public JSONObject(){
}
public JSONObject(Map map){
super(map);
}
public JSONObject(String json){
super(json);
}
}

15
src/main/java/com/fanruan/api/util/CodeKit.java

@ -0,0 +1,15 @@
package com.fanruan.api.util;
import com.fr.stable.CodeUtils;
import com.fr.stable.CommonCodeUtils;
public class CodeKit {
/**
* 给字符串解密
* @param passwordText 待解密的字符串
* @return 解密后的字符串
*/
public static String passwordDecode(String passwordText) {
return CodeUtils.passwordDecode(passwordText);
}
}

18
src/main/java/com/fanruan/api/util/DateKit.java

@ -0,0 +1,18 @@
package com.fanruan.api.util;
import com.fr.general.DateUtils;
import java.util.Date;
public class DateKit {
/**
* 将字符串转化为日期
*
* @param str 字符串
* @param returnNull 转化失败的时候是否返回null
* @return 将字符串转化为相应的日期值
*/
public static Date string2Date(String str, boolean returnNull) {
return DateUtils.string2Date(str, returnNull);
}
}

12
src/main/java/com/fanruan/api/util/GeneralKit.java

@ -2,7 +2,9 @@ package com.fanruan.api.util;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.stable.CommonUtils;
import com.fr.third.guava.base.Objects;
import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -69,4 +71,14 @@ public class GeneralKit {
public static int compare(Object obj1, Object obj2) {
return ComparatorUtils.compare(obj1, obj2);
}
/**
* 将一个数组中的元素按照给定的连接符连接成一个字符串
* @param array 数组
* @param se 连接符
* @return 连接后的字符串
*/
public static String join(Object[] array, String se) {
return StableUtils.join(array, se);
}
}

12
src/test/java/com/fanruan/api/util/CodeKitTest.java

@ -0,0 +1,12 @@
package com.fanruan.api.util;
import com.fr.stable.CommonCodeUtils;
import org.junit.Assert;
import org.junit.Test;
public class CodeKitTest {
@Test
public void passwordDecode(String passwordText) {
Assert.assertEquals(CodeKit.passwordDecode(passwordText), 123);
}
}

18
src/test/java/com/fanruan/api/util/DateKitTest.java

@ -0,0 +1,18 @@
package com.fanruan.api.util;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.junit.Assert;
import org.junit.Test;
public class DateKitTest {
@Test
public void string2Date() throws Exception{
DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
Date myDate = dateFormat2.parse("2019-02-20");
Assert.assertEquals(DateKit.string2Date("2019-02-20", false), myDate);
Assert.assertEquals(DateKit.string2Date("abcd", false), new Date());
Assert.assertEquals(DateKit.string2Date("abcd", true), null);
}
}

7
src/test/java/com/fanruan/api/util/GeneralKitTest.java

@ -39,4 +39,11 @@ public class GeneralKitTest extends Prepare {
Assert.assertEquals(GeneralKit.compare(s,s3),0);
Assert.assertEquals(GeneralKit.compare(s,s2),1);
}
@Test
public void join() {
Object obj [] = {1,2,3,4};
String result = "1-2-3-4";
Assert.assertEquals(GeneralKit.join(obj, "-"),result);
}
}
Loading…
Cancel
Save