Skip to content

Declaring variables in a class and applying multiple variables results in variables not being converted to corresponding values in the output result #177

Open
@zhenghongxun123

Description

public class StaticURI {
public final static String version3 = "/service/license/version3";

private final static String SERVICE_OPERATION = "service";
private final static String SERVICE = "/" + SERVICE_OPERATION;
public final static String version4 = SERVICE + "/pmts/convert/update";

}

// QDox构建器
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
javaProjectBuilder.setEncoding(StandardCharsets.UTF_8.name());

	// 通过addSource等相关方法, 将源码添加进QDox中 (注:可以多次添加)
	javaProjectBuilder.addSourceTree(new File(
			"D:\\sourcecodePath\\test\\smart-doc-master\\smart-doc-master\\src\\main\\java\\com\\test\\controller\\"));

	// 获取解析出来的JavaClass对象
	javaProjectBuilder.getClasses().forEach(javaClass -> {

if ("com.test.controller.StaticURI".equals(javaClass.getFullyQualifiedName())) {
System.err.println("字段\t" + javaClass.getFields());
List f = javaClass.getFields();
f.forEach(fieldRef->{
System.out.println(fieldRef.getName());
String h = fieldRef.getInitializationExpression();
System.out.println("--" + h);
});
}
}

result::::
字段 [public static final String com.test.controller.StaticURI.version3, private static final String com.test.controller.StaticURI.SERVICE_OPERATION, private static final String com.test.controller.StaticURI.SERVICE, public static final String com.test.controller.StaticURI.version4]
version3
--"/service/license/version3"
SERVICE_OPERATION
--"service"
SERVICE
--"/" + SERVICE_OPERATION
version4
--SERVICE + "/pmts/convert/update"

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions