|
@@ -10,15 +10,17 @@ import java.io.IOException;
|
|
|
|
|
|
/**
|
|
|
* 读取 json/GlobalConfig/Parameters.json
|
|
|
- * 自动生成 GlobalConfig 常量参数, 不需要手动复制然后覆盖参数
|
|
|
+ * 自动生成 GlobalConfig 全局常量参数, 不需要手动复制然后覆盖参数
|
|
|
*
|
|
|
* @author agui
|
|
|
*/
|
|
|
public final class ParamMain {
|
|
|
|
|
|
+ // 生成类路径
|
|
|
+ private final static String pathName = "src/main/java/com/incubator/game/data/data/ParametersConfig.java";
|
|
|
// java类生成头
|
|
|
private final static String START = "//================================ParamMain auto generate start================================//";
|
|
|
- public final static String END = "//================================ParamMain auto generate end================================//";
|
|
|
+ private final static String END = "//================================ParamMain auto generate end================================//";
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
loadConfig(true);
|
|
@@ -47,16 +49,20 @@ public final class ParamMain {
|
|
|
JSONArray values = (JSONArray) doc.get(i);
|
|
|
String type = values.getString(1);
|
|
|
String content = values.getString(2);
|
|
|
- builder.append("\n\t/**").append(content).append(" */").append("\n\tpublic static ").append("NUMBER".equals(type) ? "int " : "LONG".equals(type) ? "long " : "FLOAT".equals(type) ? "float " : "String ").append(values.get(0).toString().replace(".", "_")).append(";");
|
|
|
+ builder.append("\n\t/**")
|
|
|
+ .append(content).append(" */")
|
|
|
+ .append("\n\tpublic static ")
|
|
|
+ .append("NUMBER".equals(type) ? "int " : "LONG".equals(type) ? "long " : "FLOAT".equals(type) ? "float " : "String ")
|
|
|
+ .append(values.get(0).toString().replace(".", "_"))
|
|
|
+ .append(";");
|
|
|
}
|
|
|
|
|
|
builder.append("\n\n\t" + END);
|
|
|
|
|
|
- String pathName = "src/main/java/com/incubator/game/data/config/ParametersConfig.java";
|
|
|
- writeToJava(pathName, builder);
|
|
|
+ writeToJava(builder);
|
|
|
}
|
|
|
|
|
|
- private static void writeToJava(String pathName, StringBuilder builder) {
|
|
|
+ private static void writeToJava(StringBuilder builder) {
|
|
|
File msgFile = new File(pathName);
|
|
|
System.out.println(msgFile.getAbsolutePath());
|
|
|
StringBuilder msgContent = new StringBuilder(FileUtil.readText(msgFile));
|