From d228f7d2b4cc551e68ac66436368b234f8b67daf Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Wed, 28 Jun 2023 01:10:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E6=AD=A3=20Javadoc=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plusone/commons/function/Predicates.java | 6 +++--- .../zhouxy/plusone/commons/jdbc/DbRecord.java | 2 +- .../commons/jdbc/SimpleJdbcTemplate.java | 4 ++-- .../plusone/commons/util/MapWrapper.java | 2 +- .../plusone/commons/util/OptionalUtil.java | 20 +++++++++---------- .../commons/util/SnowflakeIdGenerator.java | 5 ++--- .../commons/util/SimpleJdbcTemplateTests.java | 2 +- .../commons/util/TreeBuilderTests.java | 2 +- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/main/java/xyz/zhouxy/plusone/commons/function/Predicates.java b/src/main/java/xyz/zhouxy/plusone/commons/function/Predicates.java index e1620f4..adb4989 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/function/Predicates.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/function/Predicates.java @@ -42,9 +42,9 @@ public class Predicates { * .and(StringUtils::isNotEmpty); * * - * @param - * @param predicate - * @return + * @param 目标类型 + * @param predicate 原 {@link Predicate} 实例 + * @return 包装的 {@link Predicate} 实例 */ public static Predicate of(Predicate predicate) { return predicate::test; diff --git a/src/main/java/xyz/zhouxy/plusone/commons/jdbc/DbRecord.java b/src/main/java/xyz/zhouxy/plusone/commons/jdbc/DbRecord.java index 120d26e..a233da4 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/jdbc/DbRecord.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/jdbc/DbRecord.java @@ -59,7 +59,7 @@ public class DbRecord extends AbstractMapWrapper { public Set getValueAsSet(String key) { return this.>getAndConvert(key) .map(l -> (l instanceof Set) ? (Set) l : new HashSet<>(l)) - .orElse(Collections.emptySet()); + .orElse(Collections.emptySet()); } public OptionalInt getValueAsInt(String key) { diff --git a/src/main/java/xyz/zhouxy/plusone/commons/jdbc/SimpleJdbcTemplate.java b/src/main/java/xyz/zhouxy/plusone/commons/jdbc/SimpleJdbcTemplate.java index 51d274f..819168d 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/jdbc/SimpleJdbcTemplate.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/jdbc/SimpleJdbcTemplate.java @@ -213,7 +213,7 @@ public class SimpleJdbcTemplate { int executeCount = params.size() / batchSize; executeCount = (params.size() % batchSize == 0) ? executeCount : (executeCount + 1); List result = Lists.newArrayListWithCapacity(executeCount); - + try (PreparedStatement stmt = this.conn.prepareStatement(sql)) { int i = 0; for (Object[] ps : params) { @@ -247,7 +247,7 @@ public class SimpleJdbcTemplate { } @FunctionalInterface - public static interface IAtom { + public interface IAtom { @SuppressWarnings("all") void execute() throws SQLException, T; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/MapWrapper.java b/src/main/java/xyz/zhouxy/plusone/commons/util/MapWrapper.java index 62a936f..7838df2 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/MapWrapper.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/MapWrapper.java @@ -49,7 +49,7 @@ public final class MapWrapper extends AbstractMapWrapper(new HashMap<>(initialCapacity, loadFactor)); } - public static Builder wrapTreeMap() { + public static , V> Builder wrapTreeMap() { return new Builder<>(new TreeMap<>()); } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalUtil.java b/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalUtil.java index 05808a7..57c4660 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalUtil.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalUtil.java @@ -55,16 +55,16 @@ public class OptionalUtil { } /** - * 将 {@code Optional} 转为 {@link OptionalInt}。 + * 将 {@code Optional} 对象转为 {@link OptionalInt} 对象。 *

* {@code Optional} 将整数包装了两次,改为使用 {@link OptionalInt} 包装其中的整数数据。 *

* - * @param value 包装对象 + * @param optionalObj {@code Optional} 对象 * @return {@link OptionalInt} 实例 */ - public static OptionalInt toOptionalInt(Optional objectOptional) { - return optionalOf(objectOptional.orElse(null)); + public static OptionalInt toOptionalInt(Optional optionalObj) { + return optionalOf(optionalObj.orElse(null)); } /** @@ -87,11 +87,11 @@ public class OptionalUtil { * {@code Optional} 将整数包装了两次,改为使用 {@link OptionalLong} 包装其中的整数数据。 *

* - * @param value 包装对象 + * @param optionalObj 包装对象 * @return {@link OptionalLong} 实例 */ - public static OptionalLong toOptionalLong(Optional objectOptional) { - return optionalOf(objectOptional.orElse(null)); + public static OptionalLong toOptionalLong(Optional optionalObj) { + return optionalOf(optionalObj.orElse(null)); } /** @@ -114,11 +114,11 @@ public class OptionalUtil { * {@code Optional} 将整数包装了两次,改为使用 {@link OptionalDouble} 包装其中的整数数据。 *

* - * @param value 包装对象 + * @param optionalObj 包装对象 * @return {@link OptionalDouble} 实例 */ - public static OptionalDouble toOptionalDouble(Optional objectOptional) { - return optionalOf(objectOptional.orElse(null)); + public static OptionalDouble toOptionalDouble(Optional optionalObj) { + return optionalOf(optionalObj.orElse(null)); } /** diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java b/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java index 4e410b2..810eee7 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java @@ -42,10 +42,10 @@ public class SnowflakeIdGenerator { private static final long SEQUENCE_MASK = -1L ^ (-1L << SEQUENCE_BITS); /** 工作机器 ID (0~31) */ - private long workerId; + private final long workerId; /** 数据中心 ID (0~31) */ - private long datacenterId; + private final long datacenterId; /** 毫秒内序列 (0~4095) */ private long sequence = 0L; @@ -78,7 +78,6 @@ public class SnowflakeIdGenerator { * 获得下一个ID (该方法是线程安全的) * * @return SnowflakeId - * @throws InterruptedException */ public synchronized long nextId() { long timestamp = timeGen(); diff --git a/src/test/java/xyz/zhouxy/plusone/commons/util/SimpleJdbcTemplateTests.java b/src/test/java/xyz/zhouxy/plusone/commons/util/SimpleJdbcTemplateTests.java index 02a87ab..d8574e1 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/util/SimpleJdbcTemplateTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/util/SimpleJdbcTemplateTests.java @@ -27,7 +27,7 @@ class SimpleJdbcTemplateTests { private static final Logger log = LoggerFactory.getLogger(SimpleJdbcTemplateTests.class); - DataSource dataSource; + final DataSource dataSource; String[] cStruct = { "id", diff --git a/src/test/java/xyz/zhouxy/plusone/commons/util/TreeBuilderTests.java b/src/test/java/xyz/zhouxy/plusone/commons/util/TreeBuilderTests.java index 446ec35..dd2c063 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/util/TreeBuilderTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/util/TreeBuilderTests.java @@ -31,7 +31,7 @@ class TreeBuilderTests { MenuItem.of("C", "C2", "二级菜单C2", "/c/c2"), MenuItem.of("C", "C3", "二级菜单C3", "/c/c3") ); - List menuTree = new TreeBuilder( + List menuTree = new TreeBuilder<>( menus, Menu::getMenuCode, Menu::getParentMenuCode,