-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
优化代码:对修饰符重新排序以符合 Java 语言规范。
- Loading branch information
Showing
3 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/com/wangym/lombok/job/impl/NormalizationJavaJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.wangym.lombok.job.impl; | ||
|
||
import com.wangym.lombok.job.JavaJob; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.FileCopyUtils; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
@Component | ||
@Slf4j | ||
public class NormalizationJavaJob extends JavaJob { | ||
@Override | ||
public void handle(File file) throws IOException { | ||
byte[] bytes = FileCopyUtils.copyToByteArray(file); | ||
String code = new String(bytes, "utf-8"); | ||
//Reorder the modifiers to comply with the Java Language Specification. | ||
String newBody = code.replaceAll(" final static ", " static final "); | ||
// 以utf-8编码的方式写入文件中 | ||
if (!newBody.equals(code)) { | ||
FileCopyUtils.copy(newBody.toString().getBytes("utf-8"), file); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/test/java/com/wangym/lombok/NormalizationJavaJobTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.wangym.lombok; | ||
|
||
import com.wangym.lombok.job.impl.NormalizationJavaJob; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
public class NormalizationJavaJobTest { | ||
@Autowired | ||
private NormalizationJavaJob job; | ||
|
||
@Test | ||
public void handle() throws IOException { | ||
job.handle(new ClassPathResource("CommunityType.java").getFile()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package com.wangym.community.iportal.bean; | ||
|
||
public interface CommunityType { | ||
/** | ||
* 审核通过文章 | ||
*/ | ||
public final static int PASS_ARTICLE = 335; | ||
|
||
/** | ||
* 审核不通过文章 | ||
*/ | ||
public final static int REJECT_ARTICLE = 336; | ||
|
||
/** | ||
* 删除评论回复 | ||
*/ | ||
public final static int REMOVE_COMMENT_REPLY = 330; | ||
|
||
/** | ||
* 屏蔽评论回复 | ||
*/ | ||
public final static int HIDDEN_COMMENT_REPLY = 331; | ||
|
||
/** | ||
* 审核通过评论回复 | ||
*/ | ||
public final static int PASS_COMMENT_REPLY = 332; | ||
|
||
/** | ||
* 审核不通过评论回复 | ||
*/ | ||
public final static int REJECT_COMMENT_REPLY = 333; | ||
|
||
/** | ||
* 删除专栏 | ||
*/ | ||
public final static int REMOVE_COLUMN = 323; | ||
|
||
/** | ||
* 屏蔽专栏 | ||
*/ | ||
public final static int HIDDEN_COLUMN = 324; | ||
|
||
/** | ||
* 审核通过专栏 | ||
*/ | ||
public final static int PASS_COLUMN = 325; | ||
|
||
/** | ||
* 审核不通过专栏 | ||
*/ | ||
public final static int REJECT_COLUMN = 326; | ||
|
||
/** | ||
* 审核通过专栏 | ||
*/ | ||
public final static int PASS_COMMENT = 327; | ||
|
||
/** | ||
* 审核不通过专栏 | ||
*/ | ||
public final static int REJECT_COMMENT = 328; | ||
|
||
/** | ||
* 屏蔽文章 | ||
*/ | ||
public final static int HIDDEN_ARTICLE = 308; | ||
|
||
/** | ||
* 推荐文章 | ||
*/ | ||
public final static int RECOMMEND_ARTICLE = 309; | ||
|
||
/** | ||
* 删除答案回复 | ||
*/ | ||
public final static int REMOVE_ANSWER_REPLY = 228; | ||
|
||
/** | ||
* 屏蔽答案回复 | ||
*/ | ||
public final static int HIDDEN_ANSWER_REPLY = 229; | ||
|
||
/** | ||
* 审核通过答案回复 | ||
*/ | ||
public final static int PASS_ANSWER_REPLY = 230; | ||
|
||
/** | ||
* 审核不通过答案回复 | ||
*/ | ||
public final static int REJECT_ANSWER_REPLY = 231; | ||
|
||
/** | ||
* 审核通过问题 | ||
*/ | ||
public final static int PASS_ASK = 224; | ||
|
||
/** | ||
* 审核不通过问题 | ||
*/ | ||
public final static int REJECT_ASK = 225; | ||
|
||
/** | ||
* 审核通过问题 | ||
*/ | ||
public final static int PASS_ANSWER = 226; | ||
|
||
/** | ||
* 审核不通过答案 | ||
*/ | ||
public final static int REJECT_ANSWER = 227; | ||
|
||
/** | ||
* 屏蔽问题 | ||
*/ | ||
public final static int HIDDEN_ASK = 210; | ||
|
||
/** | ||
* 屏蔽回答 | ||
*/ | ||
public final static int HIDDEN_ANSWER = 211; | ||
|
||
/** | ||
* 屏蔽评论 | ||
*/ | ||
public final static int HIDDEN_COMMENT = 212; | ||
|
||
/** | ||
* 推荐回答 | ||
*/ | ||
public final static int RECOMMEND_ANSWER = 213; | ||
|
||
/** | ||
* 禁言 | ||
*/ | ||
public final static int FORBID_SPEAKING = 105; | ||
|
||
/** | ||
* 屏蔽用户介绍 | ||
*/ | ||
public final static int HIDDEN_INTRODUCE = 106; | ||
} |