This commit is contained in:
Looly
2023-12-29 21:16:01 +08:00
parent 6facfcfc4d
commit fc8d25dfac
32 changed files with 81 additions and 69 deletions

View File

@@ -344,7 +344,7 @@ public class Hashids implements Encoder<long[], String>, Decoder<String, long[]>
LongStream decoded = LongStream.empty();
// parse the hash
if (hash.length() > 0) {
if (!hash.isEmpty()) {
final char lottery = hash.charAt(startIdx);
// create the initial accumulation string

View File

@@ -36,6 +36,11 @@ public class SetFromMap<E> extends AbstractSet<E> implements Serializable {
private final Map<E, Boolean> m; // The backing map
private transient Set<E> s; // Its keySet
/**
* 构造
*
* @param map Map
*/
public SetFromMap(final Map<E, Boolean> map) {
m = map;
s = map.keySet();
@@ -82,7 +87,6 @@ public class SetFromMap<E> extends AbstractSet<E> implements Serializable {
return s.toArray();
}
@SuppressWarnings("SuspiciousToArrayCall")
@Override
public <T> T[] toArray(final T[] a) {
return super.toArray(a);

View File

@@ -355,7 +355,7 @@ public class ComparatorChain<E> implements Chain<Comparator<E>, ComparatorChain<
* @throws UnsupportedOperationException 为空抛出此异常
*/
private void checkChainIntegrity() {
if (chain.size() == 0) {
if (chain.isEmpty()) {
throw new UnsupportedOperationException("ComparatorChains must contain at least one Comparator");
}
}

View File

@@ -43,7 +43,7 @@ public class SeataSnowflake implements Generator<Long>, Serializable {
/**
* 默认的起始时间为2020-05-03
*/
public static long DEFAULT_TWEPOCH = 1588435200000L;
public static final long DEFAULT_TWEPOCH = 1588435200000L;
// 节点ID长度
private static final int NODE_ID_BITS = 10;

View File

@@ -51,7 +51,7 @@ public class Snowflake implements Generator<Long>, Serializable {
/**
* 默认的起始时间为Thu, 04 Nov 2010 01:42:54 GMT
*/
public static long DEFAULT_TWEPOCH = 1288834974657L;
public static final long DEFAULT_TWEPOCH = 1288834974657L;
private static final long WORKER_ID_BITS = 5L;
// 最大支持机器节点数0~31一共32个
private static final long MAX_WORKER_ID = ~(-1L << WORKER_ID_BITS);

View File

@@ -36,7 +36,7 @@ public class TimeParser extends DefaultDateBasic implements PredicateDateParser
/**
* 单例
*/
public static TimeParser INSTANCE = new TimeParser();
public static final TimeParser INSTANCE = new TimeParser();
@Override
public boolean test(final CharSequence dateStr) {

View File

@@ -46,7 +46,7 @@ public final class Weighers {
final Weigher<? super V> weigher) {
return (weigher == singleton())
? Weighers.entrySingleton()
: new EntryWeigherView<K, V>(weigher);
: new EntryWeigherView<>(weigher);
}
/**

View File

@@ -193,7 +193,7 @@ public class UploadFileHeader {
if (formFileName == null) {
return;
}
if (formFileName.length() == 0) {
if (formFileName.isEmpty()) {
path = StrUtil.EMPTY;
fileName = StrUtil.EMPTY;
}
@@ -205,7 +205,7 @@ public class UploadFileHeader {
path = formFileName.substring(0, ls);
fileName = formFileName.substring(ls);
}
if (fileName.length() > 0) {
if (!fileName.isEmpty()) {
this.contentType = getContentType(dataHeader);
mimeType = getMimeType(contentType);
mimeSubtype = getMimeSubtype(contentType);

View File

@@ -26,7 +26,7 @@ public class TrustAnyHostnameVerifier implements HostnameVerifier {
/**
* 单例对象
*/
public static TrustAnyHostnameVerifier INSTANCE = new TrustAnyHostnameVerifier();
public static final TrustAnyHostnameVerifier INSTANCE = new TrustAnyHostnameVerifier();
@Override
public boolean verify(final String hostname, final SSLSession session) {

View File

@@ -34,7 +34,7 @@ public class TrustAnyTrustManager extends X509ExtendedTrustManager {
*
* @since 5.7.8
*/
public static TrustAnyTrustManager INSTANCE = new TrustAnyTrustManager();
public static final TrustAnyTrustManager INSTANCE = new TrustAnyTrustManager();
@Override
public X509Certificate[] getAcceptedIssuers() {

View File

@@ -48,7 +48,6 @@ public class ConstructorLookupFactory implements LookupFactory {
}
}
@SuppressWarnings("JavaReflectionMemberAccess")
private static Constructor<MethodHandles.Lookup> createLookupConstructor() {
final Constructor<MethodHandles.Lookup> constructor;
try {

View File

@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023. looly(loolly@aliyun.com)
* Hutool is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* https://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* spliterator实现
*
* @author Looly
*/
package org.dromara.hutool.core.stream.spliterators;

View File

@@ -29,15 +29,15 @@ public class StrTrimer implements UnaryOperator<CharSequence>, Serializable {
/**
* 去除两边空白符
*/
public static StrTrimer TRIM_BLANK = new StrTrimer(TrimMode.BOTH, CharUtil::isBlankChar);
public static final StrTrimer TRIM_BLANK = new StrTrimer(TrimMode.BOTH, CharUtil::isBlankChar);
/**
* 去除头部空白符
*/
public static StrTrimer TRIM_PREFIX_BLANK = new StrTrimer(TrimMode.PREFIX, CharUtil::isBlankChar);
public static final StrTrimer TRIM_PREFIX_BLANK = new StrTrimer(TrimMode.PREFIX, CharUtil::isBlankChar);
/**
* 去除尾部空白符
*/
public static StrTrimer TRIM_SUFFIX_BLANK = new StrTrimer(TrimMode.SUFFIX, CharUtil::isBlankChar);
public static final StrTrimer TRIM_SUFFIX_BLANK = new StrTrimer(TrimMode.SUFFIX, CharUtil::isBlankChar);
private final TrimMode mode;
private final Predicate<Character> predicate;

View File

@@ -34,7 +34,7 @@ import java.util.Map;
*/
public class StrMatcher {
List<String> patterns;
private final List<String> patterns;
/**
* 构造

View File

@@ -20,22 +20,27 @@ package org.dromara.hutool.core.text.placeholder.segment;
* @since 6.0.0
*/
public abstract class AbstractPlaceholderSegment implements StrTemplateSegment {
/**
* 占位符变量
* <p>例如:{@literal "???"->"???", "{}"->"{}", "{name}"->"name"}</p>
*/
private final String placeholder;
/**
* 占位符变量
* <p>例如:{@literal "???"->"???", "{}"->"{}", "{name}"->"name"}</p>
*/
private final String placeholder;
protected AbstractPlaceholderSegment(final String placeholder) {
this.placeholder = placeholder;
}
protected AbstractPlaceholderSegment(final String placeholder) {
this.placeholder = placeholder;
}
@Override
public String getText() {
return placeholder;
}
@Override
public String getText() {
return placeholder;
}
public String getPlaceholder() {
return placeholder;
}
/**
* 获取占位符
*
* @return 占位符
*/
public String getPlaceholder() {
return placeholder;
}
}

View File

@@ -36,7 +36,7 @@ public class SplitUtil {
/**
* 无限制切分个数
*/
public static int UNLIMITED = -1;
public static final int UNLIMITED = -1;
// region ----- split to

View File

@@ -25,7 +25,7 @@ public class TreeNodeConfig implements Serializable {
/**
* 默认属性配置对象
*/
public static TreeNodeConfig DEFAULT_CONFIG = new TreeNodeConfig();
public static final TreeNodeConfig DEFAULT_CONFIG = new TreeNodeConfig();
// 属性名配置字段
private String idKey = "id";

View File

@@ -33,7 +33,7 @@ public class SystemUtil {
/**
* Hutool自定义系统属性是否解析日期字符串采用严格模式
*/
public static String HUTOOL_DATE_LENIENT = "hutool.date.lenient";
public static final String HUTOOL_DATE_LENIENT = "hutool.date.lenient";
/**
* 取得系统属性如果因为Java安全的限制而失败则将错误打在Log中然后返回 defaultValue