Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6d2f6dd

Browse files
author
杨利兵
committed
代码优化
1 parent 8c475ef commit 6d2f6dd

File tree

8 files changed

+2
-63
lines changed

8 files changed

+2
-63
lines changed

‎src/main/java/com/yanglb/codegen/core/generator/BaseGenerator.java‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,17 @@
1515
*/
1616
package com.yanglb.codegen.core.generator;
1717

18-
import com.yanglb.codegen.model.OptionModel;
19-
import com.yanglb.codegen.model.ParamaModel;
2018
import com.yanglb.codegen.exceptions.CodeGenException;
2119
import com.yanglb.codegen.exceptions.ParamaCheckException;
20+
import com.yanglb.codegen.model.ParamaModel;
2221
import org.apache.commons.cli.CommandLine;
2322
import org.apache.commons.cli.Option;
2423

25-
import java.util.ArrayList;
2624
import java.util.Date;
2725
import java.util.HashMap;
28-
import java.util.List;
2926

3027
public class BaseGenerator implements IGenerator{
3128
protected ParamaModel paramaModel;
32-
protected List<OptionModel> supportOptions;
3329
protected HashMap<String, String> settingMap;
3430

3531
protected void printInfo() {
@@ -58,8 +54,7 @@ protected void printInfo() {
5854
*/
5955
protected void init(ParamaModel paramaModel) {
6056
this.paramaModel = paramaModel;
61-
this.supportOptions = new ArrayList<OptionModel>();
62-
this.settingMap = new HashMap<String, String>();
57+
this.settingMap = new HashMap<>();
6358

6459
this.settingMap.put("generationDate", new Date().toString());
6560
}
@@ -68,23 +63,12 @@ protected void init(ParamaModel paramaModel) {
6863
public final void invoke(ParamaModel paramaModel) throws CodeGenException, ParamaCheckException {
6964
init(paramaModel);
7065

71-
onCheck();
72-
7366
printInfo();
7467

7568
// 生成代码
7669
onGeneration();
7770
}
7871

79-
@Override
80-
public List<OptionModel> getSupportOptions() {
81-
return this.supportOptions;
82-
}
83-
84-
protected void onCheck() throws ParamaCheckException {
85-
// 如需要检查请子类自行检查
86-
}
87-
8872
protected void onGeneration() throws CodeGenException {
8973
// 子类实现
9074
}

‎src/main/java/com/yanglb/codegen/core/generator/IGenerator.java‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,4 @@ public interface IGenerator {
2929
* @throws CodeGenException 出错信息
3030
*/
3131
void invoke(ParamaModel paramaModel) throws CodeGenException, ParamaCheckException;
32-
33-
/**
34-
* 取得该生成器支持的选项
35-
* @return 该生成器支持的选项
36-
*/
37-
List<OptionModel> getSupportOptions();
3832
}

‎src/main/java/com/yanglb/codegen/core/generator/impl/MsgGeneratorImpl.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,4 @@ protected void onGeneration() throws CodeGenException {
6868
}
6969
}
7070
}
71-
7271
}

‎src/main/java/com/yanglb/codegen/core/translator/BaseTranslator.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ protected void onBeforeTranslate() throws CodeGenException {
6464
this.writableModel.setFileName("untitled");
6565
this.writableModel.setData(new StringBuilder());
6666
this.writableModel.setOutputDir(this.paramaModel.getOptDir());
67-
return;
6867
}
6968

7069
/**

‎src/main/java/com/yanglb/codegen/core/translator/ITranslator.java‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,4 @@ public interface ITranslator<T> {
3131
* @throws CodeGenException 翻译出错时抛出此异常
3232
*/
3333
WritableModel translate(HashMap<String, String> settingMap, ParamaModel paramaModel, T model) throws CodeGenException;
34-
35-
// /**
36-
// * 预翻译器(子类如果重写,则必须显示调用超类的此方法)
37-
// * @throws CodeGenException 错误信息
38-
// */
39-
// protected void onBeforeTranslate() throws CodeGenException;
40-
//
41-
// /**
42-
// * 进行转换操作
43-
// * @throws CodeGenException 错误信息
44-
// */
45-
// protected void onTranslate() throws CodeGenException;
46-
//
47-
// /**
48-
// * 编码转换等操作
49-
// * @throws CodeGenException 错误信息
50-
// */
51-
// protected void onAfterTranslate() throws CodeGenException;
52-
//
53-
// // 翻译操作
54-
// private void doTranslate() throws CodeGenException;
5534
}

‎src/main/java/com/yanglb/codegen/exceptions/CodeGenException.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
package com.yanglb.codegen.exceptions;
1717

1818
public class CodeGenException extends Exception {
19-
/**
20-
*
21-
*/
22-
private static final long serialVersionUID = 1L;
23-
2419
public CodeGenException(String errMsg) {
2520
super(errMsg);
2621
}

‎src/main/java/com/yanglb/codegen/exceptions/ParamaCheckException.java‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
package com.yanglb.codegen.exceptions;
1717

1818
public class ParamaCheckException extends Exception {
19-
20-
/**
21-
*
22-
*/
23-
private static final long serialVersionUID = 1L;
24-
2519
public ParamaCheckException() {
2620
super("您输入的参数不正确,请使用 --help 命令查看用法。");
2721
}

‎src/main/java/com/yanglb/codegen/exceptions/UnImplementException.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
package com.yanglb.codegen.exceptions;
1717

1818
public class UnImplementException extends Exception {
19-
/**
20-
*
21-
*/
22-
private static final long serialVersionUID = 1L;
23-
2419
public UnImplementException() {
2520
super("该方法未实现!");
2621
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /