mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix code
This commit is contained in:
parent
6facfcfc4d
commit
fc8d25dfac
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
@ -48,7 +48,6 @@ public class ConstructorLookupFactory implements LookupFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("JavaReflectionMemberAccess")
|
||||
private static Constructor<MethodHandles.Lookup> createLookupConstructor() {
|
||||
final Constructor<MethodHandles.Lookup> constructor;
|
||||
try {
|
||||
|
@ -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;
|
@ -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;
|
||||
|
@ -34,7 +34,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class StrMatcher {
|
||||
|
||||
List<String> patterns;
|
||||
private final List<String> patterns;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class SplitUtil {
|
||||
/**
|
||||
* 无限制切分个数
|
||||
*/
|
||||
public static int UNLIMITED = -1;
|
||||
public static final int UNLIMITED = -1;
|
||||
|
||||
// region ----- split to
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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
|
||||
|
@ -40,6 +40,11 @@ public class TaskExecutorManager implements Serializable {
|
||||
*/
|
||||
private final List<TaskExecutor> executors = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param scheduler {@link Scheduler}
|
||||
*/
|
||||
public TaskExecutorManager(final Scheduler scheduler) {
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
@ -23,16 +23,16 @@ import java.security.*;
|
||||
* 同态加密算法Paillier<br>
|
||||
* 来自:https://github.com/peterstefanov/paillier<br>
|
||||
* 来自:https://github.com/dromara/hutool/pull/3131
|
||||
*
|
||||
* <p>
|
||||
* 加法同态,存在有效算法+,E(x+y)=E(x)+E(y)或者 x+y=D(E(x)+E(y))成立,并且不泄漏 x 和 y。
|
||||
* 乘法同态,存在有效算法*,E(x×y)=E(x)*E(y)或者 xy=D(E(x)*E(y))成立,并且不泄漏 x 和 y。
|
||||
*
|
||||
* <p>
|
||||
* 方案安全性可以归约到判定性合数剩余假设(Decisional Composite Residuosity Assumption, DCRA),即给定一个合数n和整数z,判定z是否在n^2下是否是n次剩余是困难的。
|
||||
* 这个假设经过了几十年的充分研究,到目前为止还没有多项式时间的算法可以攻破,所以Paillier加密方案的安全性被认为相当可靠。
|
||||
*
|
||||
* <p>
|
||||
* 字符串文本加解密相互配对,此时无法使用同态加法和同态乘法
|
||||
* 数值类型不可使用字符串加解密
|
||||
*
|
||||
* <p>
|
||||
* 公钥加密和同态加法/同态乘法运算
|
||||
* 私钥解密
|
||||
*
|
||||
@ -45,7 +45,6 @@ public class PaillierCrypto extends AbstractAsymmetricCrypto<PaillierCrypto> {
|
||||
|
||||
/**
|
||||
* 构造,使用随机密钥对
|
||||
*
|
||||
*/
|
||||
public PaillierCrypto() {
|
||||
this(PaillierKeyPairGenerator.of().generateKeyPair());
|
||||
|
@ -264,7 +264,7 @@ public class SqlBuilder implements Builder<String> {
|
||||
sql.append("UPDATE ").append(tableName).append(" SET ");
|
||||
entity.forEach((field, value) -> {
|
||||
if (StrUtil.isNotBlank(field)) {
|
||||
if (paramValues.size() > 0) {
|
||||
if (!paramValues.isEmpty()) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append((null != quoteWrapper) ? quoteWrapper.wrap(field) : field).append(" = ? ");
|
||||
|
@ -26,7 +26,7 @@ public class SqlLog {
|
||||
/**
|
||||
* 单例
|
||||
*/
|
||||
public static SqlLog INSTANCE = new SqlLog();
|
||||
public static final SqlLog INSTANCE = new SqlLog();
|
||||
|
||||
private final static Log log = Log.get();
|
||||
|
||||
|
@ -48,8 +48,8 @@ public class SimpleFtpServer {
|
||||
return new SimpleFtpServer();
|
||||
}
|
||||
|
||||
FtpServerFactory serverFactory;
|
||||
ListenerFactory listenerFactory;
|
||||
private final FtpServerFactory serverFactory;
|
||||
private final ListenerFactory listenerFactory;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@ -37,7 +37,7 @@ public interface PinyinEngine {
|
||||
/**
|
||||
* 获取字符串对应的完整拼音,非中文返回原字符
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param str 字符串
|
||||
* @param separator 拼音之间的分隔符
|
||||
* @return 拼音
|
||||
*/
|
||||
@ -56,13 +56,13 @@ public interface PinyinEngine {
|
||||
/**
|
||||
* 将输入字符串转为拼音首字母,其它字符原样返回
|
||||
*
|
||||
* @param str 任意字符,汉字返回拼音,非汉字原样返回
|
||||
* @param str 任意字符,汉字返回拼音,非汉字原样返回
|
||||
* @param separator 分隔符
|
||||
* @return 汉字返回拼音,非汉字原样返回
|
||||
*/
|
||||
default String getFirstLetter(final String str, final String separator) {
|
||||
final String splitSeparator = StrUtil.isEmpty(separator) ? "#" : separator;
|
||||
final List<String> split = SplitUtil.split(getPinyin(str, splitSeparator), splitSeparator);
|
||||
return CollUtil.join(split, separator, (s)->String.valueOf(s.length() > 0 ? s.charAt(0) : StrUtil.EMPTY));
|
||||
return CollUtil.join(split, separator, (s) -> String.valueOf(!s.isEmpty() ? s.charAt(0) : StrUtil.EMPTY));
|
||||
}
|
||||
}
|
||||
|
@ -51,10 +51,4 @@ public class AnsjResult implements Result {
|
||||
public void remove() {
|
||||
result.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Word> iterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,17 +82,10 @@
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<version>4.12.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 仅用于测试 -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.hutool</groupId>
|
||||
<artifactId>hutool-json</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.brotli</groupId>
|
||||
<artifactId>dec</artifactId>
|
||||
|
@ -392,7 +392,6 @@ public class JakartaServletUtil {
|
||||
public static boolean isIE(final HttpServletRequest request) {
|
||||
String userAgent = getHeaderIgnoreCase(request, "User-Agent");
|
||||
if (StrUtil.isNotBlank(userAgent)) {
|
||||
//noinspection ConstantConditions
|
||||
userAgent = userAgent.toUpperCase();
|
||||
return userAgent.contains("MSIE") || userAgent.contains("TRIDENT");
|
||||
}
|
||||
|
@ -403,7 +403,6 @@ public class ServletUtil {
|
||||
public static boolean isIE(final HttpServletRequest request) {
|
||||
String userAgent = getHeaderIgnoreCase(request, "User-Agent");
|
||||
if (StrUtil.isNotBlank(userAgent)) {
|
||||
//noinspection ConstantConditions
|
||||
userAgent = userAgent.toUpperCase();
|
||||
return userAgent.contains("MSIE") || userAgent.contains("TRIDENT");
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public abstract class AbsLogEngine implements LogEngine {
|
||||
/**
|
||||
* 日志框架名,用于打印当前所用日志框架
|
||||
*/
|
||||
protected String name;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@ -40,11 +40,6 @@
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.hutool</groupId>
|
||||
<artifactId>hutool-log</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- POI -->
|
||||
<dependency>
|
||||
@ -58,7 +53,7 @@
|
||||
<dependency>
|
||||
<groupId>org.ofdrw</groupId>
|
||||
<artifactId>ofdrw-full</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<version>2.2.4</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
@ -26,6 +26,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author looly
|
||||
* @since 5.4.4
|
||||
* @param <T> 结果类型
|
||||
*/
|
||||
public class BeanSheetReader<T> implements SheetReader<List<T>> {
|
||||
|
||||
|
@ -26,6 +26,7 @@ import java.util.List;
|
||||
*
|
||||
* @author looly
|
||||
* @since 5.4.4
|
||||
* @param <T> 结果类型
|
||||
*/
|
||||
public abstract class BeanRowHandler<T> extends AbstractRowHandler<T> {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user