优化代码,改正 Javadoc。

feature/net-util
ZhouXY108 2023-06-28 01:10:28 +08:00
parent 9e388f546b
commit d228f7d2b4
8 changed files with 21 additions and 22 deletions

View File

@ -42,9 +42,9 @@ public class Predicates {
* .and(StringUtils::isNotEmpty); * .and(StringUtils::isNotEmpty);
* </pre> * </pre>
* *
* @param <T> * @param <T>
* @param predicate * @param predicate {@link Predicate}
* @return * @return {@link Predicate}
*/ */
public static <T> Predicate<T> of(Predicate<? super T> predicate) { public static <T> Predicate<T> of(Predicate<? super T> predicate) {
return predicate::test; return predicate::test;

View File

@ -59,7 +59,7 @@ public class DbRecord extends AbstractMapWrapper<String, Object, DbRecord> {
public <T> Set<T> getValueAsSet(String key) { public <T> Set<T> getValueAsSet(String key) {
return this.<Collection<T>>getAndConvert(key) return this.<Collection<T>>getAndConvert(key)
.map(l -> (l instanceof Set) ? (Set<T>) l : new HashSet<>(l)) .map(l -> (l instanceof Set) ? (Set<T>) l : new HashSet<>(l))
.orElse(Collections.<T>emptySet()); .orElse(Collections.emptySet());
} }
public OptionalInt getValueAsInt(String key) { public OptionalInt getValueAsInt(String key) {

View File

@ -213,7 +213,7 @@ public class SimpleJdbcTemplate {
int executeCount = params.size() / batchSize; int executeCount = params.size() / batchSize;
executeCount = (params.size() % batchSize == 0) ? executeCount : (executeCount + 1); executeCount = (params.size() % batchSize == 0) ? executeCount : (executeCount + 1);
List<int[]> result = Lists.newArrayListWithCapacity(executeCount); List<int[]> result = Lists.newArrayListWithCapacity(executeCount);
try (PreparedStatement stmt = this.conn.prepareStatement(sql)) { try (PreparedStatement stmt = this.conn.prepareStatement(sql)) {
int i = 0; int i = 0;
for (Object[] ps : params) { for (Object[] ps : params) {
@ -247,7 +247,7 @@ public class SimpleJdbcTemplate {
} }
@FunctionalInterface @FunctionalInterface
public static interface IAtom<T extends Exception> { public interface IAtom<T extends Exception> {
@SuppressWarnings("all") @SuppressWarnings("all")
void execute() throws SQLException, T; void execute() throws SQLException, T;
} }

View File

@ -49,7 +49,7 @@ public final class MapWrapper<K, V> extends AbstractMapWrapper<K, V, MapWrapper<
return new Builder<>(new HashMap<>(initialCapacity, loadFactor)); return new Builder<>(new HashMap<>(initialCapacity, loadFactor));
} }
public static <K, V> Builder<K, V> wrapTreeMap() { public static <K extends Comparable<? super K>, V> Builder<K, V> wrapTreeMap() {
return new Builder<>(new TreeMap<>()); return new Builder<>(new TreeMap<>());
} }

View File

@ -55,16 +55,16 @@ public class OptionalUtil {
} }
/** /**
* {@code Optional<Integer>} {@link OptionalInt} * {@code Optional<Integer>} {@link OptionalInt}
* <p> * <p>
* {@code Optional<Integer>} 使 {@link OptionalInt} * {@code Optional<Integer>} 使 {@link OptionalInt}
* </p> * </p>
* *
* @param value * @param optionalObj {@code Optional<Integer>}
* @return {@link OptionalInt} * @return {@link OptionalInt}
*/ */
public static OptionalInt toOptionalInt(Optional<Integer> objectOptional) { public static OptionalInt toOptionalInt(Optional<Integer> optionalObj) {
return optionalOf(objectOptional.orElse(null)); return optionalOf(optionalObj.orElse(null));
} }
/** /**
@ -87,11 +87,11 @@ public class OptionalUtil {
* {@code Optional<Long>} 使 {@link OptionalLong} * {@code Optional<Long>} 使 {@link OptionalLong}
* </p> * </p>
* *
* @param value * @param optionalObj
* @return {@link OptionalLong} * @return {@link OptionalLong}
*/ */
public static OptionalLong toOptionalLong(Optional<Long> objectOptional) { public static OptionalLong toOptionalLong(Optional<Long> optionalObj) {
return optionalOf(objectOptional.orElse(null)); return optionalOf(optionalObj.orElse(null));
} }
/** /**
@ -114,11 +114,11 @@ public class OptionalUtil {
* {@code Optional<Double>} 使 {@link OptionalDouble} * {@code Optional<Double>} 使 {@link OptionalDouble}
* </p> * </p>
* *
* @param value * @param optionalObj
* @return {@link OptionalDouble} * @return {@link OptionalDouble}
*/ */
public static OptionalDouble toOptionalDouble(Optional<Double> objectOptional) { public static OptionalDouble toOptionalDouble(Optional<Double> optionalObj) {
return optionalOf(objectOptional.orElse(null)); return optionalOf(optionalObj.orElse(null));
} }
/** /**

View File

@ -42,10 +42,10 @@ public class SnowflakeIdGenerator {
private static final long SEQUENCE_MASK = -1L ^ (-1L << SEQUENCE_BITS); private static final long SEQUENCE_MASK = -1L ^ (-1L << SEQUENCE_BITS);
/** 工作机器 ID (0~31) */ /** 工作机器 ID (0~31) */
private long workerId; private final long workerId;
/** 数据中心 ID (0~31) */ /** 数据中心 ID (0~31) */
private long datacenterId; private final long datacenterId;
/** 毫秒内序列 (0~4095) */ /** 毫秒内序列 (0~4095) */
private long sequence = 0L; private long sequence = 0L;
@ -78,7 +78,6 @@ public class SnowflakeIdGenerator {
* ID (线) * ID (线)
* *
* @return SnowflakeId * @return SnowflakeId
* @throws InterruptedException
*/ */
public synchronized long nextId() { public synchronized long nextId() {
long timestamp = timeGen(); long timestamp = timeGen();

View File

@ -27,7 +27,7 @@ class SimpleJdbcTemplateTests {
private static final Logger log = LoggerFactory.getLogger(SimpleJdbcTemplateTests.class); private static final Logger log = LoggerFactory.getLogger(SimpleJdbcTemplateTests.class);
DataSource dataSource; final DataSource dataSource;
String[] cStruct = { String[] cStruct = {
"id", "id",

View File

@ -31,7 +31,7 @@ class TreeBuilderTests {
MenuItem.of("C", "C2", "二级菜单C2", "/c/c2"), MenuItem.of("C", "C2", "二级菜单C2", "/c/c2"),
MenuItem.of("C", "C3", "二级菜单C3", "/c/c3") MenuItem.of("C", "C3", "二级菜单C3", "/c/c3")
); );
List<Menu> menuTree = new TreeBuilder<Menu, String>( List<Menu> menuTree = new TreeBuilder<>(
menus, menus,
Menu::getMenuCode, Menu::getMenuCode,
Menu::getParentMenuCode, Menu::getParentMenuCode,