Skip to content

Commit

Permalink
--taskid=ID20230925
Browse files Browse the repository at this point in the history
优化代码:对修饰符重新排序以符合 Java 语言规范。
  • Loading branch information
xinluke committed Sep 25, 2023
1 parent 6a25554 commit 6d1ea46
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/com/wangym/lombok/job/impl/NormalizationJavaJob.java
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 src/test/java/com/wangym/lombok/NormalizationJavaJobTest.java
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());
}

}
143 changes: 143 additions & 0 deletions src/test/resources/CommunityType.java
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;
}

0 comments on commit 6d1ea46

Please sign in to comment.