Browse Source

修改不符合规范的代码

remotes/1611766341912730171/master
richie 5 years ago
parent
commit
4513d48372
  1. 7
      pom.xml
  2. 16
      src/main/java/com/fanruan/api/util/ReflectKit.java
  3. 22
      src/main/java/com/fanruan/api/util/RenderKit.java
  4. 16
      src/main/java/com/fanruan/api/util/StableKit.java
  5. 19
      src/main/java/com/fanruan/api/util/TemplateKit.java
  6. 14
      src/test/java/com/fanruan/api/util/ReflectKitTest.java
  7. 28
      src/test/java/com/fanruan/api/util/RenderKitTest.java
  8. 14
      src/test/java/com/fanruan/api/util/StableKitTest.java

7
pom.xml

@ -90,6 +90,13 @@
<version>${common-version}</version> <version>${common-version}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- 报表设计器包 -->
<dependency>
<groupId>com.fr.report</groupId>
<artifactId>fine-report-designer</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

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

22
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<String, Object> map) throws Exception {
return TemplateUtils.renderParameter4Tpl(text, map);
}
}

16
src/main/java/com/fanruan/api/util/StableKit.java

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

19
src/main/java/com/fanruan/api/util/TemplateKit.java

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

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

28
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<String, Object> 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));
}
}

14
src/test/java/com/fanruan/api/util/StableKitTest.java

@ -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);
}
}
Loading…
Cancel
Save