format code
This commit is contained in:
parent
bb7ec63cca
commit
f6534bce8f
2
pom.xml
2
pom.xml
|
@ -1,4 +1,4 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<groupId>com.github.shalousun</groupId>
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.power.doc.model.ApiConfig;
|
|||
import com.power.doc.model.ApiDoc;
|
||||
import com.power.doc.model.ApiErrorCode;
|
||||
import com.power.doc.utils.BeetlTemplateUtil;
|
||||
|
||||
import org.beetl.core.Template;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -51,21 +51,13 @@ public class SourceBuilder {
|
|||
|
||||
|
||||
public Map<String, JavaClass> javaFilesMap = new HashMap<>();
|
||||
|
||||
private JavaProjectBuilder builder;
|
||||
|
||||
private Collection<JavaClass> javaClasses;
|
||||
|
||||
private boolean isStrict;//严格模式
|
||||
|
||||
private String packageMatch;
|
||||
|
||||
private List<ApiReqHeader> headers;
|
||||
|
||||
private String appUrl;
|
||||
|
||||
|
||||
public Map<String, CustomRespField> fieldMap = new HashMap<>();
|
||||
private JavaProjectBuilder builder;
|
||||
private Collection<JavaClass> javaClasses;
|
||||
private boolean isStrict;//严格模式
|
||||
private String packageMatch;
|
||||
private List<ApiReqHeader> headers;
|
||||
private String appUrl;
|
||||
|
||||
/**
|
||||
* if isStrict value is true,it while check all method
|
||||
|
@ -458,13 +450,13 @@ public class SourceBuilder {
|
|||
for (DocletTag docletTag : paramTags) {
|
||||
if (DocClassUtil.isIgnoreTag(docletTag.getName())) {
|
||||
continue out;
|
||||
} else if(DocTags.SINCE.equals(docletTag.getName())) {
|
||||
} else if (DocTags.SINCE.equals(docletTag.getName())) {
|
||||
since = docletTag.getValue();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (DocletTag docletTag : paramTags) {
|
||||
if(DocTags.SINCE.equals(docletTag.getName())) {
|
||||
if (DocTags.SINCE.equals(docletTag.getName())) {
|
||||
since = docletTag.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -511,8 +503,8 @@ public class SourceBuilder {
|
|||
} else {
|
||||
comment = field.getComment();
|
||||
}
|
||||
if(StringUtil.isNotEmpty(comment)){
|
||||
comment = comment.replace("\n","<br>");
|
||||
if (StringUtil.isNotEmpty(comment)) {
|
||||
comment = comment.replace("\n", "<br>");
|
||||
}
|
||||
if (DocClassUtil.isPrimitive(subTypeName)) {
|
||||
params0.append(pre);
|
||||
|
|
|
@ -50,6 +50,7 @@ public class ApiConfig {
|
|||
|
||||
/**
|
||||
* 错误码code列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
@ -138,12 +139,12 @@ public class ApiConfig {
|
|||
this.packageFilters = packageFilters;
|
||||
}
|
||||
|
||||
public void setRevisionLogs(RevisionLog... revisionLogs){
|
||||
this.revisionLogs = CollectionUtil.asList(revisionLogs);
|
||||
}
|
||||
|
||||
public List<RevisionLog> getRevisionLogs() {
|
||||
return revisionLogs;
|
||||
}
|
||||
|
||||
public void setRevisionLogs(RevisionLog... revisionLogs) {
|
||||
this.revisionLogs = CollectionUtil.asList(revisionLogs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class ApiReqHeader {
|
|||
*/
|
||||
private String desc;
|
||||
|
||||
public static ApiReqHeader header(){
|
||||
public static ApiReqHeader header() {
|
||||
return new ApiReqHeader();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class CustomRespField {
|
|||
*/
|
||||
private Object value;
|
||||
|
||||
public static CustomRespField field(){
|
||||
public static CustomRespField field() {
|
||||
return new CustomRespField();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.power.doc.model;
|
|||
|
||||
/**
|
||||
* 接口文档修订日志
|
||||
*
|
||||
* @author yolanda0608 2018/12/15
|
||||
*/
|
||||
public class RevisionLog {
|
||||
|
@ -31,7 +32,9 @@ public class RevisionLog {
|
|||
*/
|
||||
private String remarks;
|
||||
|
||||
|
||||
public static RevisionLog getLog() {
|
||||
return new RevisionLog();
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
|
@ -77,8 +80,4 @@ public class RevisionLog {
|
|||
this.remarks = remarks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static RevisionLog getLog(){
|
||||
return new RevisionLog();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,8 @@ public class BeetlTemplateUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param path path
|
||||
* @param params params
|
||||
* @param path path
|
||||
* @param params params
|
||||
* @return map
|
||||
*/
|
||||
public static Map<String, String> getTemplatesRendered(String path, Map<String, Object> params) {
|
||||
|
@ -52,13 +51,12 @@ public class BeetlTemplateUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
private static GroupTemplate getGroupTemplate(String path) {
|
||||
try {
|
||||
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("/"+path+"/");
|
||||
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("/" + path + "/");
|
||||
Configuration cfg = Configuration.defaultConfiguration();
|
||||
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
|
||||
return gt;
|
||||
|
|
|
@ -162,14 +162,14 @@ public class DocClassUtil {
|
|||
* @return array of string
|
||||
*/
|
||||
public static String[] getMapKeyValueType(String gName) {
|
||||
if(gName.contains("<")){
|
||||
if (gName.contains("<")) {
|
||||
String[] arr = new String[2];
|
||||
String key = gName.substring(gName.indexOf("<") + 1, gName.indexOf(","));
|
||||
String value = gName.substring(gName.indexOf(",") + 1, gName.lastIndexOf(">"));
|
||||
arr[0] = key;
|
||||
arr[1] = value;
|
||||
return arr;
|
||||
}else {
|
||||
} else {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ public class DocClassUtil {
|
|||
if (javaTypeName.length() == 1) {
|
||||
return "object";
|
||||
}
|
||||
if(javaTypeName.contains("[]")){
|
||||
if (javaTypeName.contains("[]")) {
|
||||
return "array";
|
||||
}
|
||||
switch (javaTypeName) {
|
||||
|
@ -309,15 +309,17 @@ public class DocClassUtil {
|
|||
|
||||
/**
|
||||
* check array
|
||||
*
|
||||
* @param type type name
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isArray(String type){
|
||||
public static boolean isArray(String type) {
|
||||
return type.contains("[]");
|
||||
}
|
||||
|
||||
/**
|
||||
* check JSR303
|
||||
*
|
||||
* @param annotationSimpleName annotation name
|
||||
* @return boolean
|
||||
*/
|
||||
|
@ -338,10 +340,11 @@ public class DocClassUtil {
|
|||
|
||||
/**
|
||||
* custom tag
|
||||
*
|
||||
* @param tagName custom field tag
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isRequiredTag(String tagName){
|
||||
public static boolean isRequiredTag(String tagName) {
|
||||
switch (tagName) {
|
||||
case "required":
|
||||
return true;
|
||||
|
@ -352,10 +355,11 @@ public class DocClassUtil {
|
|||
|
||||
/**
|
||||
* ignore tag request field
|
||||
*
|
||||
* @param tagName custom field tag
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isIgnoreTag(String tagName){
|
||||
public static boolean isIgnoreTag(String tagName) {
|
||||
switch (tagName) {
|
||||
case "ignore":
|
||||
return true;
|
||||
|
@ -366,18 +370,19 @@ public class DocClassUtil {
|
|||
|
||||
/**
|
||||
* ignore param of spring mvc
|
||||
*
|
||||
* @param paramType param type name
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMvcIgnoreParams(String paramType){
|
||||
switch (paramType){
|
||||
public static boolean isMvcIgnoreParams(String paramType) {
|
||||
switch (paramType) {
|
||||
case "org.springframework.ui.Model":
|
||||
return true;
|
||||
case "org.springframework.ui.ModelMap":
|
||||
return true;
|
||||
case "org.springframework.web.servlet.ModelAndView":
|
||||
return true;
|
||||
case "org.springframework.validation.BindingResult" :
|
||||
case "org.springframework.validation.BindingResult":
|
||||
return true;
|
||||
case "javax.servlet.http.HttpServletRequest":
|
||||
return true;
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.power.common.util.RandomUtil;
|
|||
import com.power.common.util.StringUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
|
@ -21,64 +20,66 @@ public class DocUtil {
|
|||
|
||||
private static Faker enFaker = new Faker(new Locale("en-US"));
|
||||
|
||||
private static Map<String,String> fieldValue = new LinkedHashMap<>();
|
||||
private static Map<String, String> fieldValue = new LinkedHashMap<>();
|
||||
|
||||
static {
|
||||
fieldValue.put("uuid-string", UUID.randomUUID().toString());
|
||||
fieldValue.put("uid",UUID.randomUUID().toString());
|
||||
fieldValue.put("nickname-string",enFaker.name().username());
|
||||
fieldValue.put("name-string",faker.name().username());
|
||||
fieldValue.put("url-string",faker.internet().url());
|
||||
fieldValue.put("username-string",faker.name().username());
|
||||
fieldValue.put("age-int",String.valueOf(RandomUtil.randomInt(0,70)));
|
||||
fieldValue.put("age-integer",String.valueOf(RandomUtil.randomInt(0,70)));
|
||||
fieldValue.put("email-string",faker.internet().emailAddress());
|
||||
fieldValue.put("domain-string",faker.internet().domainName());
|
||||
fieldValue.put("phone-string",faker.phoneNumber().cellPhone());
|
||||
fieldValue.put("mobile-string",faker.phoneNumber().cellPhone());
|
||||
fieldValue.put("telephone-string",faker.phoneNumber().phoneNumber());
|
||||
fieldValue.put("address-string",faker.address().fullAddress().replace(",",","));
|
||||
fieldValue.put("ip-string",faker.internet().ipV4Address());
|
||||
fieldValue.put("ipv4-string",faker.internet().ipV4Address());
|
||||
fieldValue.put("ipv6-string",faker.internet().ipV6Address());
|
||||
fieldValue.put("company-string",faker.company().name());
|
||||
fieldValue.put("timestamp-long",String.valueOf(System.currentTimeMillis()));
|
||||
fieldValue.put("timestamp-string",DateTimeUtil.dateToStr(new Date(),DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
fieldValue.put("time-long",String.valueOf(System.currentTimeMillis()));
|
||||
fieldValue.put("time-string",DateTimeUtil.dateToStr(new Date(),DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
fieldValue.put("birthday-string", DateTimeUtil.dateToStr(new Date(),DateTimeUtil.DATE_FORMAT_DAY));
|
||||
fieldValue.put("birthday-long",String.valueOf(System.currentTimeMillis()));
|
||||
fieldValue.put("code-string",String.valueOf(RandomUtil.randomInt(100,99999)));
|
||||
fieldValue.put("message-string","success,fail".split(",")[RandomUtil.randomInt(0,1)]);
|
||||
fieldValue.put("date-string",DateTimeUtil.dateToStr(new Date(),DateTimeUtil.DATE_FORMAT_DAY));
|
||||
fieldValue.put("date-date",DateTimeUtil.dateToStr(new Date(),DateTimeUtil.DATE_FORMAT_DAY));
|
||||
fieldValue.put("state-int",String.valueOf(RandomUtil.randomInt(0,10)));
|
||||
fieldValue.put("state-integer",String.valueOf(RandomUtil.randomInt(0,10)));
|
||||
fieldValue.put("flag-int",String.valueOf(RandomUtil.randomInt(0,10)));
|
||||
fieldValue.put("flag-integer",String.valueOf(RandomUtil.randomInt(0,10)));
|
||||
fieldValue.put("flag-boolean","true");
|
||||
fieldValue.put("flag-Boolean","false");
|
||||
fieldValue.put("uid", UUID.randomUUID().toString());
|
||||
fieldValue.put("nickname-string", enFaker.name().username());
|
||||
fieldValue.put("name-string", faker.name().username());
|
||||
fieldValue.put("url-string", faker.internet().url());
|
||||
fieldValue.put("username-string", faker.name().username());
|
||||
fieldValue.put("age-int", String.valueOf(RandomUtil.randomInt(0, 70)));
|
||||
fieldValue.put("age-integer", String.valueOf(RandomUtil.randomInt(0, 70)));
|
||||
fieldValue.put("email-string", faker.internet().emailAddress());
|
||||
fieldValue.put("domain-string", faker.internet().domainName());
|
||||
fieldValue.put("phone-string", faker.phoneNumber().cellPhone());
|
||||
fieldValue.put("mobile-string", faker.phoneNumber().cellPhone());
|
||||
fieldValue.put("telephone-string", faker.phoneNumber().phoneNumber());
|
||||
fieldValue.put("address-string", faker.address().fullAddress().replace(",", ","));
|
||||
fieldValue.put("ip-string", faker.internet().ipV4Address());
|
||||
fieldValue.put("ipv4-string", faker.internet().ipV4Address());
|
||||
fieldValue.put("ipv6-string", faker.internet().ipV6Address());
|
||||
fieldValue.put("company-string", faker.company().name());
|
||||
fieldValue.put("timestamp-long", String.valueOf(System.currentTimeMillis()));
|
||||
fieldValue.put("timestamp-string", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
fieldValue.put("time-long", String.valueOf(System.currentTimeMillis()));
|
||||
fieldValue.put("time-string", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
fieldValue.put("birthday-string", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_DAY));
|
||||
fieldValue.put("birthday-long", String.valueOf(System.currentTimeMillis()));
|
||||
fieldValue.put("code-string", String.valueOf(RandomUtil.randomInt(100, 99999)));
|
||||
fieldValue.put("message-string", "success,fail".split(",")[RandomUtil.randomInt(0, 1)]);
|
||||
fieldValue.put("date-string", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_DAY));
|
||||
fieldValue.put("date-date", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_DAY));
|
||||
fieldValue.put("state-int", String.valueOf(RandomUtil.randomInt(0, 10)));
|
||||
fieldValue.put("state-integer", String.valueOf(RandomUtil.randomInt(0, 10)));
|
||||
fieldValue.put("flag-int", String.valueOf(RandomUtil.randomInt(0, 10)));
|
||||
fieldValue.put("flag-integer", String.valueOf(RandomUtil.randomInt(0, 10)));
|
||||
fieldValue.put("flag-boolean", "true");
|
||||
fieldValue.put("flag-Boolean", "false");
|
||||
fieldValue.put("idcard-string", IDCardUtil.getIdCard());
|
||||
fieldValue.put("sex-int",String.valueOf(RandomUtil.randomInt(0,1)));
|
||||
fieldValue.put("sex-integer",String.valueOf(RandomUtil.randomInt(0,1)));
|
||||
fieldValue.put("gender-int",String.valueOf(RandomUtil.randomInt(0,1)));
|
||||
fieldValue.put("gender-integer",String.valueOf(RandomUtil.randomInt(0,1)));
|
||||
fieldValue.put("sex-int", String.valueOf(RandomUtil.randomInt(0, 1)));
|
||||
fieldValue.put("sex-integer", String.valueOf(RandomUtil.randomInt(0, 1)));
|
||||
fieldValue.put("gender-int", String.valueOf(RandomUtil.randomInt(0, 1)));
|
||||
fieldValue.put("gender-integer", String.valueOf(RandomUtil.randomInt(0, 1)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机生成json值
|
||||
*
|
||||
* @param type0 type name
|
||||
* @return string
|
||||
*/
|
||||
public static String jsonValueByType(String type0){
|
||||
String type = type0.contains(".")?type0.substring(type0.lastIndexOf(".")+1,type0.length()):type0;
|
||||
public static String jsonValueByType(String type0) {
|
||||
String type = type0.contains(".") ? type0.substring(type0.lastIndexOf(".") + 1, type0.length()) : type0;
|
||||
String value = RandomUtil.randomValueByType(type);
|
||||
if("Integer".equals(type)||"int".equals(type)||"Long".equals(type)||"long".equals(type)
|
||||
||"Double".equals(type)||"double".equals(type)|| "Float".equals(type)||"float".equals(type)||
|
||||
"BigDecimal".equals(type)||"boolean".equals(type)||"Boolean".equals(type)||
|
||||
"Short".equals(type)||"BigInteger".equals(type)){
|
||||
if ("Integer".equals(type) || "int".equals(type) || "Long".equals(type) || "long".equals(type)
|
||||
|| "Double".equals(type) || "double".equals(type) || "Float".equals(type) || "float".equals(type) ||
|
||||
"BigDecimal".equals(type) || "boolean".equals(type) || "Boolean".equals(type) ||
|
||||
"Short".equals(type) || "BigInteger".equals(type)) {
|
||||
return value;
|
||||
}else{
|
||||
} else {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("\"").append(value).append("\"");
|
||||
return builder.toString();
|
||||
|
@ -87,28 +88,29 @@ public class DocUtil {
|
|||
|
||||
/**
|
||||
* 根据字段字段名和type生成字段值
|
||||
* @param type0 类型
|
||||
*
|
||||
* @param type0 类型
|
||||
* @param filedName 字段名称
|
||||
* @return string
|
||||
*/
|
||||
public static String getValByTypeAndFieldName(String type0,String filedName){
|
||||
String type = type0.contains("java.lang")?type0.substring(type0.lastIndexOf(".")+1,type0.length()):type0;
|
||||
String key = filedName.toLowerCase()+"-"+type.toLowerCase();
|
||||
public static String getValByTypeAndFieldName(String type0, String filedName) {
|
||||
String type = type0.contains("java.lang") ? type0.substring(type0.lastIndexOf(".") + 1, type0.length()) : type0;
|
||||
String key = filedName.toLowerCase() + "-" + type.toLowerCase();
|
||||
String value = null;
|
||||
for(Map.Entry<String,String> entry:fieldValue.entrySet()){
|
||||
if(key.contains(entry.getKey())){
|
||||
for (Map.Entry<String, String> entry : fieldValue.entrySet()) {
|
||||
if (key.contains(entry.getKey())) {
|
||||
value = entry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(null == value){
|
||||
if (null == value) {
|
||||
return jsonValueByType(type0);
|
||||
}else{
|
||||
if("string".equals(type.toLowerCase())){
|
||||
} else {
|
||||
if ("string".equals(type.toLowerCase())) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("\"").append(value).append("\"");
|
||||
return builder.toString();
|
||||
}else{
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -116,30 +118,32 @@ public class DocUtil {
|
|||
|
||||
/**
|
||||
* 是否是合法的java类名称
|
||||
*
|
||||
* @param className class nem
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isClassName(String className){
|
||||
if(StringUtil.isEmpty(className)){
|
||||
public static boolean isClassName(String className) {
|
||||
if (StringUtil.isEmpty(className)) {
|
||||
return false;
|
||||
}
|
||||
if(className.contains("<")&&!className.contains(">")){
|
||||
if (className.contains("<") && !className.contains(">")) {
|
||||
return false;
|
||||
}else if(className.contains(">")&&!className.contains("<")){
|
||||
} else if (className.contains(">") && !className.contains("<")) {
|
||||
return false;
|
||||
}else{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* match controller package
|
||||
*
|
||||
* @param packageFilters package filter
|
||||
* @param controllerName controller name
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(String packageFilters,String controllerName){
|
||||
if(StringUtil.isNotEmpty(packageFilters)){
|
||||
public static boolean isMatch(String packageFilters, String controllerName) {
|
||||
if (StringUtil.isNotEmpty(packageFilters)) {
|
||||
String[] patterns = packageFilters.split(",");
|
||||
for (String str : patterns) {
|
||||
if (str.endsWith("*")) {
|
||||
|
@ -148,9 +152,9 @@ public class DocUtil {
|
|||
return true;
|
||||
}
|
||||
} else {
|
||||
if(controllerName.contains(str)){
|
||||
return true;
|
||||
}
|
||||
if (controllerName.contains(str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ import java.io.File;
|
|||
public class PathUtil {
|
||||
|
||||
/**
|
||||
* 获取java类名
|
||||
* 获取java类名
|
||||
*
|
||||
* @param parentDir parent dir
|
||||
* @param className 类名
|
||||
* @return string
|
||||
|
@ -21,6 +22,6 @@ public class PathUtil {
|
|||
parentDir += File.separator;
|
||||
}
|
||||
className = className.replaceAll("\\.", "\\" + File.separator);
|
||||
return parentDir + className+".java";
|
||||
return parentDir + className + ".java";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.power.doc;
|
|||
|
||||
import com.power.common.util.DateTimeUtil;
|
||||
import com.power.doc.builder.ApiDocBuilder;
|
||||
import com.power.doc.model.*;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.RevisionLog;
|
||||
import com.power.doc.model.SourcePath;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,11 +20,8 @@ public class Main {
|
|||
System.out.println(sb.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (br != null)
|
||||
{
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (Exception e) {
|
||||
|
@ -36,9 +33,9 @@ public class Main {
|
|||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class cls = CommonResult.class;
|
||||
System.out.println("path:"+cls.getResource(""));
|
||||
System.out.println("path:" + cls.getResource(""));
|
||||
String path = cls.getResource("").getPath();
|
||||
String commandStr = String.format("javap -classpath %s -private CommonResult",path);
|
||||
String commandStr = String.format("javap -classpath %s -private CommonResult", path);
|
||||
String cmd = "java -jar d:/procyon-decompiler-0.5.30.jar D:/ProgramFiles/mvnrepository/repository/com/boco/sp/Common-util/1.0-SNAPSHOT/Common-util-1.0-20180105.062727-5.jar -o out";
|
||||
//String commandStr = "ipconfig";
|
||||
Main.exeCmd(cmd);
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.junit.Test;
|
|||
public class DocClassUtilTest {
|
||||
|
||||
@Test
|
||||
public void testGetSimpleGicName(){
|
||||
public void testGetSimpleGicName() {
|
||||
char me = 'k';
|
||||
String className = "com.power.doc.controller.Teacher<com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>,com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>,com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>>";
|
||||
String[] arr = DocClassUtil.getSimpleGicName(className);
|
||||
|
@ -20,7 +20,7 @@ public class DocClassUtilTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIsPrimitive(){
|
||||
public void testIsPrimitive() {
|
||||
String typeName = "java.time.LocalDateTime";
|
||||
System.out.println(DocClassUtil.isPrimitive(typeName));
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ import org.junit.Test;
|
|||
public class DocUtilTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
String str = DocUtil.getValByTypeAndFieldName("LocalDateTime","createTime");
|
||||
public void test() {
|
||||
String str = DocUtil.getValByTypeAndFieldName("LocalDateTime", "createTime");
|
||||
System.out.println(str);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue