style: 格式化代码

This commit is contained in:
zhouxy108 2025-04-09 21:44:59 +08:00
parent bca4ce531a
commit a05fc6cfe1
6 changed files with 23 additions and 32 deletions

View File

@ -26,9 +26,9 @@ import xyz.zhouxy.plusone.commons.util.StringTools;
*/
public interface IDCardNumber {
static final char DEFAULT_REPLACED_CHAR = '*';
static final int DEFAULT_DISPLAY_FRONT = 1;
static final int DEFAULT_DISPLAY_END = 2;
char DEFAULT_REPLACED_CHAR = '*';
int DEFAULT_DISPLAY_FRONT = 1;
int DEFAULT_DISPLAY_END = 2;
/**
* 身份证号

View File

@ -81,7 +81,7 @@ class IWithCodeTests {
assertThrows(NullPointerException.class, () -> WithLongCode.INSTANCE.isCodeEquals(longCode));
}
private static enum WithCode implements IWithCode<String> {
private enum WithCode implements IWithCode<String> {
INSTANCE("testCode"),
SAME_CODE_INSTANCE("testCode"),
WRONG_CODE_INSTANCE("wrongCode"),
@ -102,7 +102,7 @@ class IWithCodeTests {
}
}
private static enum WithIntCode implements IWithIntCode {
private enum WithIntCode implements IWithIntCode {
INSTANCE(0),
SAME_CODE_INSTANCE(0),
WRONG_CODE_INSTANCE(1),
@ -120,7 +120,7 @@ class IWithCodeTests {
}
}
private static enum WithLongCode implements IWithLongCode {
private enum WithLongCode implements IWithLongCode {
INSTANCE(0L),
SAME_CODE_INSTANCE(0L),
WRONG_CODE_INSTANCE(108L),

View File

@ -181,13 +181,13 @@ public class PagingAndSortingQueryParamsTests {
}
AccountQueryParams queryParams = jackson.readValue(WRONG_JSON_STR, AccountQueryParams.class);
assertThrows(IllegalArgumentException.class, () -> queryParams.buildPagingParams()); // NOSONAR
assertThrows(IllegalArgumentException.class, queryParams::buildPagingParams);
}
static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Test
void testGson() throws Exception {
void testGson() {
Gson gson = new GsonBuilder()
.registerTypeAdapter(LocalDate.class, new TypeAdapter<LocalDate>() {
@ -226,7 +226,7 @@ public class PagingAndSortingQueryParamsTests {
}
AccountQueryParams queryParams = gson.fromJson(WRONG_JSON_STR, AccountQueryParams.class);
assertThrows(IllegalArgumentException.class, () -> queryParams.buildPagingParams()); // NOSONAR
assertThrows(IllegalArgumentException.class, queryParams::buildPagingParams);
}
}

View File

@ -38,9 +38,7 @@ class QuarterTests {
assertEquals(1, quarter.getValue());
assertEquals("Q1", quarter.name());
assertThrows(DateTimeException.class, () -> {
Quarter.of(0);
});
assertThrows(DateTimeException.class, () -> Quarter.of(0));
// ==========
@ -85,9 +83,7 @@ class QuarterTests {
assertEquals(2, quarter.getValue());
assertEquals("Q2", quarter.name());
assertThrows(DateTimeException.class, () -> {
Quarter.of(5);
});
assertThrows(DateTimeException.class, () -> Quarter.of(5));
// ==========
@ -132,9 +128,7 @@ class QuarterTests {
assertEquals(3, quarter.getValue());
assertEquals("Q3", quarter.name());
assertThrows(IllegalArgumentException.class, () -> {
Quarter.valueOf("Abc");
});
assertThrows(IllegalArgumentException.class, () -> Quarter.valueOf("Abc"));
// ==========
@ -179,9 +173,7 @@ class QuarterTests {
assertEquals(4, quarter.getValue());
assertEquals("Q4", quarter.name());
assertThrows(IllegalArgumentException.class, () -> {
Quarter.valueOf("Q5");
});
assertThrows(IllegalArgumentException.class, () -> Quarter.valueOf("Q5"));
// ==========

View File

@ -37,9 +37,8 @@ import cn.hutool.core.collection.ConcurrentHashSet;
public class IdGeneratorTests {
final ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
final ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>());
@Test
void testSnowflakeIdGenerator() { // NOSONAR
@ -48,7 +47,7 @@ public class IdGeneratorTests {
for (int i = 0; i < 10000; i++) {
executor.execute(() -> {
for (int j = 0; j < 50000; j++) {
if (false == ids.add(snowflake.nextId())) {
if (!ids.add(snowflake.nextId())) {
throw new RuntimeException("重复ID");
}
}

View File

@ -87,19 +87,19 @@ class TreeBuilderTests {
Arrays.stream(new Menu[] { B001, B002, B003, B004 })
.sorted(Comparator.comparing(Menu::getOrderNum))
.collect(Collectors.toList()),
MenuList.class.cast(menuMap.get("B")).children);
((MenuList) menuMap.get("B")).children);
assertEquals(
Arrays.stream(new Menu[] { C1, C2, C3 })
.sorted(Comparator.comparing(Menu::getOrderNum))
.collect(Collectors.toList()),
MenuList.class.cast(menuMap.get("C")).children);
((MenuList) menuMap.get("C")).children);
assertEquals(
Arrays.stream(new Menu[] { C1001, C1002 })
.sorted(Comparator.comparing(Menu::getOrderNum))
.collect(Collectors.toList()),
MenuList.class.cast(menuMap.get("C1")).children);
((MenuList) menuMap.get("C1")).children);
}
@ -125,18 +125,18 @@ class TreeBuilderTests {
}
assertEquals(ImmutableList.of(B001, B002, B003, B004),
MenuList.class.cast(menuMap.get("B")).children);
((MenuList) menuMap.get("B")).children);
assertEquals(ImmutableList.of(C1, C2, C3),
MenuList.class.cast(menuMap.get("C")).children);
((MenuList) menuMap.get("C")).children);
assertEquals(ImmutableList.of(C1001, C1002),
MenuList.class.cast(menuMap.get("C1")).children);
((MenuList) menuMap.get("C1")).children);
}
@ToString
@EqualsAndHashCode
private static abstract class Menu implements Serializable { // NOSONAR
private abstract static class Menu implements Serializable {
protected final String parentMenuCode;
protected final String menuCode;
protected final String title;