mirror of
https://gitee.com/dromara/hutool.git
synced 2025-07-18 13:26:45 +08:00
fix comment
This commit is contained in:
parent
9cc095463e
commit
c17c5bb013
@ -22,6 +22,7 @@ import cn.hutool.v7.core.lang.Assert;
|
|||||||
import cn.hutool.v7.core.util.ByteUtil;
|
import cn.hutool.v7.core.util.ByteUtil;
|
||||||
import cn.hutool.v7.core.util.RandomUtil;
|
import cn.hutool.v7.core.util.RandomUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -52,6 +53,7 @@ import java.util.Random;
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
public class ULID implements Comparable<ULID>, Serializable {
|
public class ULID implements Comparable<ULID>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,6 +176,9 @@ public class ULID implements Comparable<ULID>, Serializable {
|
|||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 16位ID值
|
||||||
|
*/
|
||||||
private final Number128 idValue;
|
private final Number128 idValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,6 +90,9 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
|
|||||||
private static final AtomicLong lastV7time = new AtomicLong(0);
|
private static final AtomicLong lastV7time = new AtomicLong(0);
|
||||||
private static final long NANOS_PER_MILLI = 1_000_000;
|
private static final long NANOS_PER_MILLI = 1_000_000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 16位ID值
|
||||||
|
*/
|
||||||
private final Number128 idValue;
|
private final Number128 idValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ import cn.hutool.v7.core.date.DateFormatPool;
|
|||||||
import cn.hutool.v7.core.date.format.parser.FastDateParser;
|
import cn.hutool.v7.core.date.format.parser.FastDateParser;
|
||||||
import cn.hutool.v7.core.date.format.parser.PositionDateParser;
|
import cn.hutool.v7.core.date.format.parser.PositionDateParser;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.FieldPosition;
|
import java.text.FieldPosition;
|
||||||
import java.text.Format;
|
import java.text.Format;
|
||||||
@ -49,6 +50,7 @@ import java.util.TimeZone;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FastDateFormat extends Format implements PositionDateParser, DatePrinter {
|
public class FastDateFormat extends Format implements PositionDateParser, DatePrinter {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 8097890768636183236L;
|
private static final long serialVersionUID = 8097890768636183236L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +77,13 @@ public class FastDateFormat extends Format implements PositionDateParser, DatePr
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FastDatePrinter}日期格式生成器
|
||||||
|
*/
|
||||||
private final FastDatePrinter printer;
|
private final FastDatePrinter printer;
|
||||||
|
/**
|
||||||
|
* {@link FastDateParser}日期格式解析器
|
||||||
|
*/
|
||||||
private final FastDateParser parser;
|
private final FastDateParser parser;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
@ -19,6 +19,7 @@ package cn.hutool.v7.core.date.format;
|
|||||||
import cn.hutool.v7.core.date.format.parser.FastDateParser;
|
import cn.hutool.v7.core.date.format.parser.FastDateParser;
|
||||||
import cn.hutool.v7.core.text.StrUtil;
|
import cn.hutool.v7.core.text.StrUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
@ -29,8 +30,12 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
* @see FastDateParser
|
* @see FastDateParser
|
||||||
*/
|
*/
|
||||||
public class FastDatePrinter extends SimpleDateBasic implements DatePrinter {
|
public class FastDatePrinter extends SimpleDateBasic implements DatePrinter {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -6305750172255764887L;
|
private static final long serialVersionUID = -6305750172255764887L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期模式
|
||||||
|
*/
|
||||||
private final DatePattern datePattern;
|
private final DatePattern datePattern;
|
||||||
/**
|
/**
|
||||||
* 缓存的Calendar对象,用于减少对象创建。参考tomcat的ConcurrentDateFormat
|
* 缓存的Calendar对象,用于减少对象创建。参考tomcat的ConcurrentDateFormat
|
||||||
|
@ -50,9 +50,15 @@ public class FastDateParser extends SimpleDateBasic implements PositionDateParse
|
|||||||
* 世纪:2000年前为19, 之后为20
|
* 世纪:2000年前为19, 之后为20
|
||||||
*/
|
*/
|
||||||
private final int century;
|
private final int century;
|
||||||
|
/**
|
||||||
|
* 起始年份
|
||||||
|
*/
|
||||||
private final int startYear;
|
private final int startYear;
|
||||||
|
|
||||||
// derived fields
|
// derived fields
|
||||||
|
/**
|
||||||
|
* 缓存的解析策略
|
||||||
|
*/
|
||||||
private transient List<StrategyAndWidth> patterns;
|
private transient List<StrategyAndWidth> patterns;
|
||||||
|
|
||||||
// comparator used to sort regex alternatives
|
// comparator used to sort regex alternatives
|
||||||
|
@ -20,6 +20,7 @@ import cn.hutool.v7.core.date.CalendarUtil;
|
|||||||
import cn.hutool.v7.core.date.DateException;
|
import cn.hutool.v7.core.date.DateException;
|
||||||
import cn.hutool.v7.core.date.DateTime;
|
import cn.hutool.v7.core.date.DateTime;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -32,6 +33,7 @@ import java.util.Locale;
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
public class PatternsDateParser implements DateParser, Serializable {
|
public class PatternsDateParser implements DateParser, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +46,13 @@ public class PatternsDateParser implements DateParser, Serializable {
|
|||||||
return new PatternsDateParser(parsePatterns);
|
return new PatternsDateParser(parsePatterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析格式
|
||||||
|
*/
|
||||||
private String[] parsePatterns;
|
private String[] parsePatterns;
|
||||||
|
/**
|
||||||
|
* 地区
|
||||||
|
*/
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,7 @@ import cn.hutool.v7.core.text.CharUtil;
|
|||||||
import cn.hutool.v7.core.text.StrUtil;
|
import cn.hutool.v7.core.text.StrUtil;
|
||||||
import cn.hutool.v7.core.text.dfa.WordTree;
|
import cn.hutool.v7.core.text.dfa.WordTree;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
@ -45,6 +46,7 @@ import java.util.regex.Pattern;
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class RegexDateParser implements DateParser, Serializable {
|
public class RegexDateParser implements DateParser, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final int[] NSS = {100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1};
|
private static final int[] NSS = {100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1};
|
||||||
@ -75,7 +77,13 @@ public class RegexDateParser implements DateParser, Serializable {
|
|||||||
return new RegexDateParser(ListUtil.of(patterns));
|
return new RegexDateParser(ListUtil.of(patterns));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式列表
|
||||||
|
*/
|
||||||
private final List<Pattern> patterns;
|
private final List<Pattern> patterns;
|
||||||
|
/**
|
||||||
|
* {@code true}默认为mm/dd,否则dd/mm
|
||||||
|
*/
|
||||||
private boolean preferMonthFirst;
|
private boolean preferMonthFirst;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -296,15 +304,14 @@ public class RegexDateParser implements DateParser, Serializable {
|
|||||||
|
|
||||||
private static int parseYear(final String year) {
|
private static int parseYear(final String year) {
|
||||||
final int length = year.length();
|
final int length = year.length();
|
||||||
switch (length) {
|
return switch (length) {
|
||||||
case 4:
|
case 4 -> Integer.parseInt(year);
|
||||||
return Integer.parseInt(year);
|
case 2 -> {
|
||||||
case 2:
|
|
||||||
final int num = Integer.parseInt(year);
|
final int num = Integer.parseInt(year);
|
||||||
return (num > 50 ? 1900 : 2000) + num;
|
yield (num > 50 ? 1900 : 2000) + num;
|
||||||
default:
|
}
|
||||||
throw new DateException("Invalid year: [{}]", year);
|
default -> throw new DateException("Invalid year: [{}]", year);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package cn.hutool.v7.core.date.format.parser;
|
|||||||
import cn.hutool.v7.core.collection.ListUtil;
|
import cn.hutool.v7.core.collection.ListUtil;
|
||||||
import cn.hutool.v7.core.date.DateException;
|
import cn.hutool.v7.core.date.DateException;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,6 +32,7 @@ import java.util.List;
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
public class RegisterDateParser implements DateParser, Serializable {
|
public class RegisterDateParser implements DateParser, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,6 +40,9 @@ public class RegisterDateParser implements DateParser, Serializable {
|
|||||||
*/
|
*/
|
||||||
public static final RegisterDateParser INSTANCE = new RegisterDateParser();
|
public static final RegisterDateParser INSTANCE = new RegisterDateParser();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期解析器列表
|
||||||
|
*/
|
||||||
private final List<PredicateDateParser> parserList;
|
private final List<PredicateDateParser> parserList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,15 +16,20 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.exception;
|
package cn.hutool.v7.core.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 带有状态码的异常
|
* 带有状态码的异常
|
||||||
*
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class StatefulException extends HutoolException {
|
public class StatefulException extends HutoolException {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
// 异常状态码
|
/**
|
||||||
|
* 异常状态码
|
||||||
|
*/
|
||||||
private int status;
|
private int status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ package cn.hutool.v7.core.func;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.lang.Assert;
|
import cn.hutool.v7.core.lang.Assert;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ import java.util.function.Function;
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
public class ComposeFunction<A, B, C> implements Function<A, C>, Serializable {
|
public class ComposeFunction<A, B, C> implements Function<A, C>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +49,13 @@ public class ComposeFunction<A, B, C> implements Function<A, C>, Serializable {
|
|||||||
return new ComposeFunction<>(g, f);
|
return new ComposeFunction<>(g, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 函数1
|
||||||
|
*/
|
||||||
private final Function<B, C> g;
|
private final Function<B, C> g;
|
||||||
|
/**
|
||||||
|
* 函数2
|
||||||
|
*/
|
||||||
private final Function<A, ? extends B> f;
|
private final Function<A, ? extends B> f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,7 @@ import cn.hutool.v7.core.lang.Assert;
|
|||||||
import cn.hutool.v7.core.array.ArrayUtil;
|
import cn.hutool.v7.core.array.ArrayUtil;
|
||||||
import cn.hutool.v7.core.util.CharsetUtil;
|
import cn.hutool.v7.core.util.CharsetUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -40,6 +41,7 @@ import java.util.function.Predicate;
|
|||||||
* @author Apache-commons-io
|
* @author Apache-commons-io
|
||||||
*/
|
*/
|
||||||
public class ByteOrderMark implements Predicate<byte[]>, Comparable<ByteOrderMark>, Serializable {
|
public class ByteOrderMark implements Predicate<byte[]>, Comparable<ByteOrderMark>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
// region ----- BOMs
|
// region ----- BOMs
|
||||||
@ -85,7 +87,13 @@ public class ByteOrderMark implements Predicate<byte[]>, Comparable<ByteOrderMar
|
|||||||
};
|
};
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BOM头
|
||||||
|
*/
|
||||||
private final String charsetName;
|
private final String charsetName;
|
||||||
|
/**
|
||||||
|
* BOM bytes
|
||||||
|
*/
|
||||||
private final byte[] bytes;
|
private final byte[] bytes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,10 +171,9 @@ public class ByteOrderMark implements Predicate<byte[]>, Comparable<ByteOrderMar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (!(obj instanceof ByteOrderMark)) {
|
if (!(obj instanceof final ByteOrderMark bom)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ByteOrderMark bom = (ByteOrderMark) obj;
|
|
||||||
return Arrays.equals(this.bytes, bom.bytes);
|
return Arrays.equals(this.bytes, bom.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ package cn.hutool.v7.core.io.checksum;
|
|||||||
import cn.hutool.v7.core.io.checksum.crc16.CRC16Checksum;
|
import cn.hutool.v7.core.io.checksum.crc16.CRC16Checksum;
|
||||||
import cn.hutool.v7.core.io.checksum.crc16.CRC16IBM;
|
import cn.hutool.v7.core.io.checksum.crc16.CRC16IBM;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.zip.Checksum;
|
import java.util.zip.Checksum;
|
||||||
|
|
||||||
@ -29,8 +30,12 @@ import java.util.zip.Checksum;
|
|||||||
* @since 4.4.1
|
* @since 4.4.1
|
||||||
*/
|
*/
|
||||||
public class CRC16 implements Checksum, Serializable {
|
public class CRC16 implements Checksum, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CRC16实现
|
||||||
|
*/
|
||||||
private final CRC16Checksum crc16;
|
private final CRC16Checksum crc16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.io.checksum;
|
package cn.hutool.v7.core.io.checksum;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.zip.Checksum;
|
import java.util.zip.Checksum;
|
||||||
|
|
||||||
@ -27,10 +28,20 @@ import java.util.zip.Checksum;
|
|||||||
* @since 4.4.1
|
* @since 4.4.1
|
||||||
*/
|
*/
|
||||||
public class CRC8 implements Checksum, Serializable {
|
public class CRC8 implements Checksum, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CRC8-CCITT polynomial.
|
||||||
|
*/
|
||||||
private final short init;
|
private final short init;
|
||||||
|
/**
|
||||||
|
* CRC8-CCITT table.
|
||||||
|
*/
|
||||||
private final short[] crcTable = new short[256];
|
private final short[] crcTable = new short[256];
|
||||||
|
/**
|
||||||
|
* CRC8 value.
|
||||||
|
*/
|
||||||
private short value;
|
private short value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,7 @@ import cn.hutool.v7.core.util.ObjUtil;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -38,8 +39,12 @@ import java.util.concurrent.locks.Lock;
|
|||||||
* @since 3.1.2
|
* @since 3.1.2
|
||||||
*/
|
*/
|
||||||
public class FileAppender implements Serializable {
|
public class FileAppender implements Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件写入器
|
||||||
|
*/
|
||||||
private final FileWriter writer;
|
private final FileWriter writer;
|
||||||
/**
|
/**
|
||||||
* 内存中持有的字符串数
|
* 内存中持有的字符串数
|
||||||
|
@ -34,8 +34,17 @@ import java.nio.file.WatchKey;
|
|||||||
*/
|
*/
|
||||||
public class LineReadWatcher extends SimpleWatcher implements Runnable {
|
public class LineReadWatcher extends SimpleWatcher implements Runnable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 随机访问文件
|
||||||
|
*/
|
||||||
private final RandomAccessFile randomAccessFile;
|
private final RandomAccessFile randomAccessFile;
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
private final Charset charset;
|
private final Charset charset;
|
||||||
|
/**
|
||||||
|
* 行处理器{@link SerConsumer}实现
|
||||||
|
*/
|
||||||
private final SerConsumer<String> lineHandler;
|
private final SerConsumer<String> lineHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +23,7 @@ import cn.hutool.v7.core.lang.copier.SrcToTargetCopier;
|
|||||||
import cn.hutool.v7.core.util.ObjUtil;
|
import cn.hutool.v7.core.util.ObjUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Serial;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +33,7 @@ import java.nio.file.*;
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
public class PathCopier extends SrcToTargetCopier<Path, PathCopier> {
|
public class PathCopier extends SrcToTargetCopier<Path, PathCopier> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,6 +60,9 @@ public class PathCopier extends SrcToTargetCopier<Path, PathCopier> {
|
|||||||
return new PathCopier(src, target, options);
|
return new PathCopier(src, target, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复制参数
|
||||||
|
*/
|
||||||
private final CopyOption[] options;
|
private final CopyOption[] options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +70,7 @@ public class PathCopier extends SrcToTargetCopier<Path, PathCopier> {
|
|||||||
*
|
*
|
||||||
* @param src 源文件或目录,不能为{@code null}且必须存在
|
* @param src 源文件或目录,不能为{@code null}且必须存在
|
||||||
* @param target 目标文件或目录
|
* @param target 目标文件或目录
|
||||||
* @param options 移动参数
|
* @param options 复制参数
|
||||||
*/
|
*/
|
||||||
public PathCopier(final Path src, final Path target, final CopyOption[] options) {
|
public PathCopier(final Path src, final Path target, final CopyOption[] options) {
|
||||||
Assert.notNull(target, "Src path must be not null !");
|
Assert.notNull(target, "Src path must be not null !");
|
||||||
|
@ -29,10 +29,7 @@ import cn.hutool.v7.core.lang.Console;
|
|||||||
import cn.hutool.v7.core.text.CharUtil;
|
import cn.hutool.v7.core.text.CharUtil;
|
||||||
import cn.hutool.v7.core.util.CharsetUtil;
|
import cn.hutool.v7.core.util.CharsetUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.RandomAccessFile;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.WatchEvent;
|
import java.nio.file.WatchEvent;
|
||||||
import java.nio.file.WatchKey;
|
import java.nio.file.WatchKey;
|
||||||
@ -46,6 +43,7 @@ import java.util.concurrent.*;
|
|||||||
* @since 4.5.2
|
* @since 4.5.2
|
||||||
*/
|
*/
|
||||||
public class Tailer implements Serializable {
|
public class Tailer implements Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,26 +51,48 @@ public class Tailer implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public static final SerConsumer<String> CONSOLE_HANDLER = new ConsoleLineHandler();
|
public static final SerConsumer<String> CONSOLE_HANDLER = new ConsoleLineHandler();
|
||||||
|
|
||||||
/** 编码 */
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
private final Charset charset;
|
private final Charset charset;
|
||||||
/** 行处理器 */
|
/**
|
||||||
|
* 行处理器
|
||||||
|
*/
|
||||||
private final SerConsumer<String> lineHandler;
|
private final SerConsumer<String> lineHandler;
|
||||||
/** 初始读取的行数 */
|
/**
|
||||||
|
* 初始读取的行数
|
||||||
|
*/
|
||||||
private final int initReadLine;
|
private final int initReadLine;
|
||||||
/** 定时任务检查间隔时长 */
|
/**
|
||||||
|
* 定时任务检查间隔时长
|
||||||
|
*/
|
||||||
private final long period;
|
private final long period;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
*/
|
||||||
private final String filePath;
|
private final String filePath;
|
||||||
|
/**
|
||||||
|
* 随机访问文件
|
||||||
|
*/
|
||||||
private final RandomAccessFile randomAccessFile;
|
private final RandomAccessFile randomAccessFile;
|
||||||
|
/**
|
||||||
|
* 定时任务执行器
|
||||||
|
*/
|
||||||
private final ScheduledExecutorService executorService;
|
private final ScheduledExecutorService executorService;
|
||||||
|
/**
|
||||||
|
* 文件删除监听器
|
||||||
|
*/
|
||||||
private WatchMonitor fileDeleteWatchMonitor;
|
private WatchMonitor fileDeleteWatchMonitor;
|
||||||
|
/**
|
||||||
|
* 删除文件后是否退出并抛出异常
|
||||||
|
*/
|
||||||
private boolean stopOnDelete;
|
private boolean stopOnDelete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造,默认UTF-8编码
|
* 构造,默认UTF-8编码
|
||||||
*
|
*
|
||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @param lineHandler 行处理器
|
* @param lineHandler 行处理器
|
||||||
*/
|
*/
|
||||||
public Tailer(final File file, final SerConsumer<String> lineHandler) {
|
public Tailer(final File file, final SerConsumer<String> lineHandler) {
|
||||||
@ -82,8 +102,8 @@ public class Tailer implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 构造,默认UTF-8编码
|
* 构造,默认UTF-8编码
|
||||||
*
|
*
|
||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @param lineHandler 行处理器
|
* @param lineHandler 行处理器
|
||||||
* @param initReadLine 启动时预读取的行数,1表示一行
|
* @param initReadLine 启动时预读取的行数,1表示一行
|
||||||
*/
|
*/
|
||||||
public Tailer(final File file, final SerConsumer<String> lineHandler, final int initReadLine) {
|
public Tailer(final File file, final SerConsumer<String> lineHandler, final int initReadLine) {
|
||||||
@ -93,8 +113,8 @@ public class Tailer implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 构造
|
* 构造
|
||||||
*
|
*
|
||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @param charset 编码
|
* @param charset 编码
|
||||||
* @param lineHandler 行处理器
|
* @param lineHandler 行处理器
|
||||||
*/
|
*/
|
||||||
public Tailer(final File file, final Charset charset, final SerConsumer<String> lineHandler) {
|
public Tailer(final File file, final Charset charset, final SerConsumer<String> lineHandler) {
|
||||||
@ -104,11 +124,11 @@ public class Tailer implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 构造
|
* 构造
|
||||||
*
|
*
|
||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @param charset 编码
|
* @param charset 编码
|
||||||
* @param lineHandler 行处理器
|
* @param lineHandler 行处理器
|
||||||
* @param initReadLine 启动时预读取的行数,1表示一行
|
* @param initReadLine 启动时预读取的行数,1表示一行
|
||||||
* @param period 检查间隔
|
* @param period 检查间隔
|
||||||
*/
|
*/
|
||||||
public Tailer(final File file, final Charset charset, final SerConsumer<String> lineHandler, final int initReadLine, final long period) {
|
public Tailer(final File file, final Charset charset, final SerConsumer<String> lineHandler, final int initReadLine, final long period) {
|
||||||
checkFile(file);
|
checkFile(file);
|
||||||
@ -152,15 +172,16 @@ public class Tailer implements Serializable {
|
|||||||
|
|
||||||
final LineReadWatcher lineReadWatcher = new LineReadWatcher(this.randomAccessFile, this.charset, this.lineHandler);
|
final LineReadWatcher lineReadWatcher = new LineReadWatcher(this.randomAccessFile, this.charset, this.lineHandler);
|
||||||
final ScheduledFuture<?> scheduledFuture = this.executorService.scheduleAtFixedRate(//
|
final ScheduledFuture<?> scheduledFuture = this.executorService.scheduleAtFixedRate(//
|
||||||
lineReadWatcher, //
|
lineReadWatcher, //
|
||||||
0, //
|
0, //
|
||||||
this.period, TimeUnit.MILLISECONDS//
|
this.period, TimeUnit.MILLISECONDS//
|
||||||
);
|
);
|
||||||
|
|
||||||
// 监听删除
|
// 监听删除
|
||||||
if(stopOnDelete){
|
if (stopOnDelete) {
|
||||||
fileDeleteWatchMonitor = WatchUtil.of(this.filePath, WatchKind.DELETE.getValue());
|
fileDeleteWatchMonitor = WatchUtil.of(this.filePath, WatchKind.DELETE.getValue());
|
||||||
fileDeleteWatchMonitor.setWatcher(new SimpleWatcher(){
|
fileDeleteWatchMonitor.setWatcher(new SimpleWatcher() {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 4497160994840060329L;
|
private static final long serialVersionUID = 4497160994840060329L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -187,8 +208,8 @@ public class Tailer implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 结束,此方法需在异步模式或
|
* 结束,此方法需在异步模式或
|
||||||
*/
|
*/
|
||||||
public void stop(){
|
public void stop() {
|
||||||
try{
|
try {
|
||||||
this.executorService.shutdown();
|
this.executorService.shutdown();
|
||||||
} finally {
|
} finally {
|
||||||
IoUtil.closeQuietly(this.randomAccessFile);
|
IoUtil.closeQuietly(this.randomAccessFile);
|
||||||
@ -197,6 +218,7 @@ public class Tailer implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------- Private method start
|
// ---------------------------------------------------------------------------------------- Private method start
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预读取行
|
* 预读取行
|
||||||
*
|
*
|
||||||
@ -225,7 +247,7 @@ public class Tailer implements Serializable {
|
|||||||
if (c == CharUtil.LF || c == CharUtil.CR) {
|
if (c == CharUtil.LF || c == CharUtil.CR) {
|
||||||
// FileUtil.readLine(this.randomAccessFile, this.charset, this.lineHandler);
|
// FileUtil.readLine(this.randomAccessFile, this.charset, this.lineHandler);
|
||||||
final String line = FileUtil.readLine(this.randomAccessFile, this.charset);
|
final String line = FileUtil.readLine(this.randomAccessFile, this.charset);
|
||||||
if(null != line) {
|
if (null != line) {
|
||||||
stack.push(line);
|
stack.push(line);
|
||||||
}
|
}
|
||||||
currentLine++;
|
currentLine++;
|
||||||
@ -237,7 +259,7 @@ public class Tailer implements Serializable {
|
|||||||
// 当文件指针退至文件开始处,输出第一行
|
// 当文件指针退至文件开始处,输出第一行
|
||||||
// FileUtil.readLine(this.randomAccessFile, this.charset, this.lineHandler);
|
// FileUtil.readLine(this.randomAccessFile, this.charset, this.lineHandler);
|
||||||
final String line = FileUtil.readLine(this.randomAccessFile, this.charset);
|
final String line = FileUtil.readLine(this.randomAccessFile, this.charset);
|
||||||
if(null != line) {
|
if (null != line) {
|
||||||
stack.push(line);
|
stack.push(line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -280,7 +302,9 @@ public class Tailer implements Serializable {
|
|||||||
* @since 4.5.2
|
* @since 4.5.2
|
||||||
*/
|
*/
|
||||||
public static class ConsoleLineHandler implements SerConsumer<String> {
|
public static class ConsoleLineHandler implements SerConsumer<String> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accepting(final String line) {
|
public void accepting(final String line) {
|
||||||
Console.log(line);
|
Console.log(line);
|
||||||
|
@ -21,6 +21,7 @@ import cn.hutool.v7.core.text.StrUtil;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@ -33,9 +34,16 @@ import java.nio.charset.Charset;
|
|||||||
* @since 4.0.9
|
* @since 4.0.9
|
||||||
*/
|
*/
|
||||||
public class BytesResource implements Resource, Serializable {
|
public class BytesResource implements Resource, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字节数据
|
||||||
|
*/
|
||||||
private final byte[] bytes;
|
private final byte[] bytes;
|
||||||
|
/**
|
||||||
|
* 资源名称
|
||||||
|
*/
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,8 +39,17 @@ public class ClassPathResource extends UrlResource {
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路径
|
||||||
|
*/
|
||||||
private final String path;
|
private final String path;
|
||||||
|
/**
|
||||||
|
* 类加载器
|
||||||
|
*/
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
|
/**
|
||||||
|
* 基于的类
|
||||||
|
*/
|
||||||
private final Class<?> clazz;
|
private final Class<?> clazz;
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------- Constructor start
|
// -------------------------------------------------------------------------------------- Constructor start
|
||||||
|
@ -37,8 +37,17 @@ public class FileResource implements Resource, Serializable {
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件
|
||||||
|
*/
|
||||||
private final File file;
|
private final File file;
|
||||||
|
/**
|
||||||
|
* 文件最后修改时间
|
||||||
|
*/
|
||||||
private final long lastModified;
|
private final long lastModified;
|
||||||
|
/**
|
||||||
|
* 文件名
|
||||||
|
*/
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- Constructor start
|
// ----------------------------------------------------------------------- Constructor start
|
||||||
|
@ -19,6 +19,7 @@ package cn.hutool.v7.core.io.resource;
|
|||||||
import cn.hutool.v7.core.lang.Assert;
|
import cn.hutool.v7.core.lang.Assert;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@ -29,9 +30,16 @@ import java.net.URL;
|
|||||||
* @since 5.7.17
|
* @since 5.7.17
|
||||||
*/
|
*/
|
||||||
public class HttpResource implements Resource, Serializable {
|
public class HttpResource implements Resource, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源
|
||||||
|
*/
|
||||||
private final Resource resource;
|
private final Resource resource;
|
||||||
|
/**
|
||||||
|
* Content-Type类型
|
||||||
|
*/
|
||||||
private final String contentType;
|
private final String contentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,10 +19,7 @@ package cn.hutool.v7.core.io.resource;
|
|||||||
import cn.hutool.v7.core.io.IORuntimeException;
|
import cn.hutool.v7.core.io.IORuntimeException;
|
||||||
import cn.hutool.v7.core.io.stream.ReaderInputStream;
|
import cn.hutool.v7.core.io.stream.ReaderInputStream;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
@ -34,9 +31,16 @@ import java.nio.charset.Charset;
|
|||||||
* @since 4.0.9
|
* @since 4.0.9
|
||||||
*/
|
*/
|
||||||
public class InputStreamResource implements Resource, Serializable {
|
public class InputStreamResource implements Resource, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link InputStream}
|
||||||
|
*/
|
||||||
private final InputStream in;
|
private final InputStream in;
|
||||||
|
/**
|
||||||
|
* 资源名称
|
||||||
|
*/
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ import cn.hutool.v7.core.io.IORuntimeException;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@ -37,9 +38,16 @@ import java.util.List;
|
|||||||
* @since 4.1.0
|
* @since 4.1.0
|
||||||
*/
|
*/
|
||||||
public class MultiResource implements Resource, Iterable<Resource>, Iterator<Resource>, Serializable {
|
public class MultiResource implements Resource, Iterable<Resource>, Iterator<Resource>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源列表
|
||||||
|
*/
|
||||||
private final List<Resource> resources;
|
private final List<Resource> resources;
|
||||||
|
/**
|
||||||
|
* 游标
|
||||||
|
*/
|
||||||
private int cursor;
|
private int cursor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,7 @@ import cn.hutool.v7.core.util.ObjUtil;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -34,6 +35,7 @@ import java.net.URL;
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class UrlResource implements Resource, Serializable {
|
public class UrlResource implements Resource, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,6 +46,9 @@ public class UrlResource implements Resource, Serializable {
|
|||||||
* 资源名称
|
* 资源名称
|
||||||
*/
|
*/
|
||||||
protected String name;
|
protected String name;
|
||||||
|
/**
|
||||||
|
* 最后修改时间
|
||||||
|
*/
|
||||||
private long lastModified = 0;
|
private long lastModified = 0;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------- Constructor start
|
//-------------------------------------------------------------------------------------- Constructor start
|
||||||
|
@ -22,6 +22,7 @@ import cn.hutool.v7.core.text.CharUtil;
|
|||||||
import cn.hutool.v7.core.text.StrUtil;
|
import cn.hutool.v7.core.text.StrUtil;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.WatchEvent;
|
import java.nio.file.WatchEvent;
|
||||||
@ -37,8 +38,12 @@ import java.nio.file.WatchEvent;
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class WatchMonitor extends Thread implements Closeable, Serializable {
|
public class WatchMonitor extends Thread implements Closeable, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听服务
|
||||||
|
*/
|
||||||
private final WatchServiceWrapper watchService;
|
private final WatchServiceWrapper watchService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,7 @@ import cn.hutool.v7.core.collection.ListUtil;
|
|||||||
import cn.hutool.v7.core.comparator.CompareUtil;
|
import cn.hutool.v7.core.comparator.CompareUtil;
|
||||||
import cn.hutool.v7.core.text.CharUtil;
|
import cn.hutool.v7.core.text.CharUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,6 +32,7 @@ import java.util.List;
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class Version implements Comparable<Version>, Serializable {
|
public class Version implements Comparable<Version>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,10 +46,22 @@ public class Version implements Comparable<Version>, Serializable {
|
|||||||
return new Version(v);
|
return new Version(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本
|
||||||
|
*/
|
||||||
private final String version;
|
private final String version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主版本号
|
||||||
|
*/
|
||||||
private final List<Object> sequence;
|
private final List<Object> sequence;
|
||||||
|
/**
|
||||||
|
* 次版本号
|
||||||
|
*/
|
||||||
private final List<Object> pre;
|
private final List<Object> pre;
|
||||||
|
/**
|
||||||
|
* 构建版本
|
||||||
|
*/
|
||||||
private final List<Object> build;
|
private final List<Object> build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.lang.mutable;
|
package cn.hutool.v7.core.lang.mutable;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,8 +26,12 @@ import java.io.Serializable;
|
|||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class MutableBool implements Comparable<MutableBool>, Mutable<Boolean>, Serializable {
|
public class MutableBool implements Comparable<MutableBool>, Mutable<Boolean>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
private boolean value;
|
private boolean value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,8 @@ package cn.hutool.v7.core.lang.mutable;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.comparator.CompareUtil;
|
import cn.hutool.v7.core.comparator.CompareUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可变 {@code byte} 类型
|
* 可变 {@code byte} 类型
|
||||||
*
|
*
|
||||||
@ -25,8 +27,12 @@ import cn.hutool.v7.core.comparator.CompareUtil;
|
|||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class MutableByte extends Number implements Comparable<MutableByte>, Mutable<Number> {
|
public class MutableByte extends Number implements Comparable<MutableByte>, Mutable<Number> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
private byte value;
|
private byte value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,8 @@ package cn.hutool.v7.core.lang.mutable;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.comparator.CompareUtil;
|
import cn.hutool.v7.core.comparator.CompareUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可变 {@code double} 类型
|
* 可变 {@code double} 类型
|
||||||
*
|
*
|
||||||
@ -25,8 +27,12 @@ import cn.hutool.v7.core.comparator.CompareUtil;
|
|||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class MutableDouble extends Number implements Comparable<MutableDouble>, Mutable<Number> {
|
public class MutableDouble extends Number implements Comparable<MutableDouble>, Mutable<Number> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
private double value;
|
private double value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,8 @@ package cn.hutool.v7.core.lang.mutable;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.comparator.CompareUtil;
|
import cn.hutool.v7.core.comparator.CompareUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可变 {@code float} 类型
|
* 可变 {@code float} 类型
|
||||||
*
|
*
|
||||||
@ -25,8 +27,12 @@ import cn.hutool.v7.core.comparator.CompareUtil;
|
|||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class MutableFloat extends Number implements Comparable<MutableFloat>, Mutable<Number> {
|
public class MutableFloat extends Number implements Comparable<MutableFloat>, Mutable<Number> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
private float value;
|
private float value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,8 @@ package cn.hutool.v7.core.lang.mutable;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.comparator.CompareUtil;
|
import cn.hutool.v7.core.comparator.CompareUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可变 {@code int} 类型
|
* 可变 {@code int} 类型
|
||||||
*
|
*
|
||||||
@ -25,8 +27,12 @@ import cn.hutool.v7.core.comparator.CompareUtil;
|
|||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class MutableInt extends Number implements Comparable<MutableInt>, Mutable<Number> {
|
public class MutableInt extends Number implements Comparable<MutableInt>, Mutable<Number> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,8 @@ package cn.hutool.v7.core.lang.mutable;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.comparator.CompareUtil;
|
import cn.hutool.v7.core.comparator.CompareUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可变 {@code long} 类型
|
* 可变 {@code long} 类型
|
||||||
*
|
*
|
||||||
@ -25,8 +27,12 @@ import cn.hutool.v7.core.comparator.CompareUtil;
|
|||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class MutableLong extends Number implements Comparable<MutableLong>, Mutable<Number> {
|
public class MutableLong extends Number implements Comparable<MutableLong>, Mutable<Number> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
private long value;
|
private long value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ package cn.hutool.v7.core.lang.mutable;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.util.ObjUtil;
|
import cn.hutool.v7.core.util.ObjUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ import java.util.Objects;
|
|||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class MutableObj<T> implements Mutable<T>, Serializable{
|
public class MutableObj<T> implements Mutable<T>, Serializable{
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,6 +43,9 @@ public class MutableObj<T> implements Mutable<T>, Serializable{
|
|||||||
return new MutableObj<>(value);
|
return new MutableObj<>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
private T value;
|
private T value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,8 @@ package cn.hutool.v7.core.lang.mutable;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.comparator.CompareUtil;
|
import cn.hutool.v7.core.comparator.CompareUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可变 {@code short} 类型
|
* 可变 {@code short} 类型
|
||||||
*
|
*
|
||||||
@ -25,8 +27,12 @@ import cn.hutool.v7.core.comparator.CompareUtil;
|
|||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class MutableShort extends Number implements Comparable<MutableShort>, Mutable<Number> {
|
public class MutableShort extends Number implements Comparable<MutableShort>, Mutable<Number> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
private short value;
|
private short value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.lang.selector;
|
package cn.hutool.v7.core.lang.selector;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,8 +27,12 @@ import java.util.ArrayList;
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
public class IncrementSelector<T> extends ArrayList<T> implements Selector<T> {
|
public class IncrementSelector<T> extends ArrayList<T> implements Selector<T> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值索引
|
||||||
|
*/
|
||||||
private int position;
|
private int position;
|
||||||
|
|
||||||
// region ----- Constructors
|
// region ----- Constructors
|
||||||
|
@ -18,6 +18,7 @@ package cn.hutool.v7.core.lang.selector;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.collection.CollUtil;
|
import cn.hutool.v7.core.collection.CollUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@ -41,6 +42,7 @@ import java.util.TreeMap;
|
|||||||
* @since 3.3.0
|
* @since 3.3.0
|
||||||
*/
|
*/
|
||||||
public class WeightRandomSelector<T> implements Selector<T>, Serializable {
|
public class WeightRandomSelector<T> implements Selector<T>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -8244697995702786499L;
|
private static final long serialVersionUID = -8244697995702786499L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +55,9 @@ public class WeightRandomSelector<T> implements Selector<T>, Serializable {
|
|||||||
return new WeightRandomSelector<>();
|
return new WeightRandomSelector<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权重对象
|
||||||
|
*/
|
||||||
private final TreeMap<Integer, T> weightMap;
|
private final TreeMap<Integer, T> weightMap;
|
||||||
|
|
||||||
// region ----- Constructors
|
// region ----- Constructors
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.map;
|
package cn.hutool.v7.core.map;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -31,8 +32,12 @@ import java.util.function.Function;
|
|||||||
* @since 5.2.6
|
* @since 5.2.6
|
||||||
*/
|
*/
|
||||||
public class BiMap<K, V> extends MapWrapper<K, V> {
|
public class BiMap<K, V> extends MapWrapper<K, V> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反向Map
|
||||||
|
*/
|
||||||
private Map<V, K> inverse;
|
private Map<V, K> inverse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.map;
|
package cn.hutool.v7.core.map;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@ -28,8 +29,12 @@ import java.util.function.Function;
|
|||||||
* @since 5.6.0
|
* @since 5.6.0
|
||||||
*/
|
*/
|
||||||
public class FuncKeyMap<K, V> extends CustomKeyMap<K, V> {
|
public class FuncKeyMap<K, V> extends CustomKeyMap<K, V> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义KEY的函数
|
||||||
|
*/
|
||||||
private final Function<Object, K> keyFunc;
|
private final Function<Object, K> keyFunc;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------- Constructor start
|
// ------------------------------------------------------------------------- Constructor start
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.map;
|
package cn.hutool.v7.core.map;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -29,9 +30,16 @@ import java.util.function.Supplier;
|
|||||||
* @since 5.8.0
|
* @since 5.8.0
|
||||||
*/
|
*/
|
||||||
public class FuncMap<K, V> extends TransMap<K, V> {
|
public class FuncMap<K, V> extends TransMap<K, V> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义KEY的函数
|
||||||
|
*/
|
||||||
private final Function<Object, K> keyFunc;
|
private final Function<Object, K> keyFunc;
|
||||||
|
/**
|
||||||
|
* 自定义value函数
|
||||||
|
*/
|
||||||
private final Function<Object, V> valueFunc;
|
private final Function<Object, V> valueFunc;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------- Constructor start
|
// ------------------------------------------------------------------------- Constructor start
|
||||||
|
@ -19,6 +19,7 @@ package cn.hutool.v7.core.map;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.lang.builder.Builder;
|
import cn.hutool.v7.core.lang.builder.Builder;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ -30,8 +31,12 @@ import java.util.function.Supplier;
|
|||||||
* @since 3.1.1
|
* @since 3.1.1
|
||||||
*/
|
*/
|
||||||
public class MapBuilder<K, V> implements Builder<Map<K, V>> {
|
public class MapBuilder<K, V> implements Builder<Map<K, V>> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map
|
||||||
|
*/
|
||||||
private final Map<K, V> map;
|
private final Map<K, V> map;
|
||||||
|
|
||||||
// region ----- of
|
// region ----- of
|
||||||
|
@ -23,6 +23,7 @@ import cn.hutool.v7.core.text.StrUtil;
|
|||||||
import cn.hutool.v7.core.array.ArrayUtil;
|
import cn.hutool.v7.core.array.ArrayUtil;
|
||||||
import cn.hutool.v7.core.util.BooleanUtil;
|
import cn.hutool.v7.core.util.BooleanUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -38,8 +39,12 @@ import java.util.Set;
|
|||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public class MapProxy implements Map<Object, Object>, TypeGetter<Object>, InvocationHandler, Serializable {
|
public class MapProxy implements Map<Object, Object>, TypeGetter<Object>, InvocationHandler, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map
|
||||||
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Map map;
|
Map map;
|
||||||
|
|
||||||
|
@ -20,10 +20,7 @@ import cn.hutool.v7.core.lang.Assert;
|
|||||||
import cn.hutool.v7.core.lang.wrapper.Wrapper;
|
import cn.hutool.v7.core.lang.wrapper.Wrapper;
|
||||||
import cn.hutool.v7.core.util.ObjUtil;
|
import cn.hutool.v7.core.util.ObjUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -39,6 +36,7 @@ import java.util.function.Supplier;
|
|||||||
* @since 4.3.3
|
* @since 4.3.3
|
||||||
*/
|
*/
|
||||||
public class MapWrapper<K, V> implements Map<K, V>, Iterable<Map.Entry<K, V>>, Wrapper<Map<K, V>>, Serializable, Cloneable {
|
public class MapWrapper<K, V> implements Map<K, V>, Iterable<Map.Entry<K, V>>, Wrapper<Map<K, V>>, Serializable, Cloneable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -7524578042008586382L;
|
private static final long serialVersionUID = -7524578042008586382L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,11 +239,25 @@ public class MapWrapper<K, V> implements Map<K, V>, Iterable<Map.Entry<K, V>>, W
|
|||||||
//---------------------------------------------------------------------------- Override default methods end
|
//---------------------------------------------------------------------------- Override default methods end
|
||||||
|
|
||||||
// region 序列化与反序列化重写
|
// region 序列化与反序列化重写
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写对象
|
||||||
|
* @param out 输出流
|
||||||
|
* @throws IOException IO异常
|
||||||
|
*/
|
||||||
|
@Serial
|
||||||
private void writeObject(final ObjectOutputStream out) throws IOException {
|
private void writeObject(final ObjectOutputStream out) throws IOException {
|
||||||
out.defaultWriteObject();
|
out.defaultWriteObject();
|
||||||
out.writeObject(this.raw);
|
out.writeObject(this.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读对象
|
||||||
|
* @param in 输入流
|
||||||
|
* @throws IOException IO异常
|
||||||
|
* @throws ClassNotFoundException 类未找到异常
|
||||||
|
*/
|
||||||
|
@Serial
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
|
@ -20,6 +20,7 @@ import cn.hutool.v7.core.collection.CollUtil;
|
|||||||
import cn.hutool.v7.core.collection.ListUtil;
|
import cn.hutool.v7.core.collection.ListUtil;
|
||||||
import cn.hutool.v7.core.util.ObjUtil;
|
import cn.hutool.v7.core.util.ObjUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -43,11 +44,21 @@ import java.util.function.BiFunction;
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class TableMap<K, V> implements Map<K, V>, Iterable<Map.Entry<K, V>>, Serializable {
|
public class TableMap<K, V> implements Map<K, V>, Iterable<Map.Entry<K, V>>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认初始大小
|
||||||
|
*/
|
||||||
private static final int DEFAULT_CAPACITY = 10;
|
private static final int DEFAULT_CAPACITY = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 键列表
|
||||||
|
*/
|
||||||
private final List<K> keys;
|
private final List<K> keys;
|
||||||
|
/**
|
||||||
|
* 值列表
|
||||||
|
*/
|
||||||
private final List<V> values;
|
private final List<V> values;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.map;
|
package cn.hutool.v7.core.map;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -28,8 +29,12 @@ import java.util.Objects;
|
|||||||
* @author pantao, Looly
|
* @author pantao, Looly
|
||||||
*/
|
*/
|
||||||
public class TolerantMap<K, V> extends MapWrapper<K, V> {
|
public class TolerantMap<K, V> extends MapWrapper<K, V> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -4158133823263496197L;
|
private static final long serialVersionUID = -4158133823263496197L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认值
|
||||||
|
*/
|
||||||
private final V defaultValue;
|
private final V defaultValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,7 @@ import cn.hutool.v7.core.collection.ListUtil;
|
|||||||
import cn.hutool.v7.core.lang.Assert;
|
import cn.hutool.v7.core.lang.Assert;
|
||||||
import cn.hutool.v7.core.lang.tuple.Triple;
|
import cn.hutool.v7.core.lang.tuple.Triple;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -36,10 +37,20 @@ import java.util.List;
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
public class TripleTable<L, M, R> implements Serializable {
|
public class TripleTable<L, M, R> implements Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 左列表
|
||||||
|
*/
|
||||||
private final List<L> lefts;
|
private final List<L> lefts;
|
||||||
|
/**
|
||||||
|
* 中列表
|
||||||
|
*/
|
||||||
private final List<M> middles;
|
private final List<M> middles;
|
||||||
|
/**
|
||||||
|
* 右列表
|
||||||
|
*/
|
||||||
private final List<R> rights;
|
private final List<R> rights;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,7 +187,13 @@ public final class ConcurrentLinkedHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
final long[] readBufferReadCount;
|
final long[] readBufferReadCount;
|
||||||
final LinkedDeque<Node<K, V>> evictionDeque;
|
final LinkedDeque<Node<K, V>> evictionDeque;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of weighted entries in the map.
|
||||||
|
*/
|
||||||
final AtomicLong weightedSize;
|
final AtomicLong weightedSize;
|
||||||
|
/**
|
||||||
|
* Map容量
|
||||||
|
*/
|
||||||
final AtomicLong capacity;
|
final AtomicLong capacity;
|
||||||
|
|
||||||
final Lock evictionLock;
|
final Lock evictionLock;
|
||||||
@ -1441,11 +1447,20 @@ public final class ConcurrentLinkedHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1;
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 序列化对象
|
||||||
|
* @return 缓存对象
|
||||||
|
*/
|
||||||
@Serial
|
@Serial
|
||||||
Object writeReplace() {
|
Object writeReplace() {
|
||||||
return new SerializationProxy<>(this);
|
return new SerializationProxy<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反序列化对象
|
||||||
|
* @param stream 对象流
|
||||||
|
* @throws InvalidObjectException 无效对象异常
|
||||||
|
*/
|
||||||
@Serial
|
@Serial
|
||||||
private void readObject(final ObjectInputStream stream) throws InvalidObjectException {
|
private void readObject(final ObjectInputStream stream) throws InvalidObjectException {
|
||||||
throw new InvalidObjectException("Proxy required");
|
throw new InvalidObjectException("Proxy required");
|
||||||
|
@ -18,6 +18,7 @@ package cn.hutool.v7.core.map.multi;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.func.SerSupplier;
|
import cn.hutool.v7.core.func.SerSupplier;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -35,9 +36,12 @@ import java.util.function.Supplier;
|
|||||||
* @since 4.3.3
|
* @since 4.3.3
|
||||||
*/
|
*/
|
||||||
public class CollectionValueMap<K, V> extends AbsCollValueMap<K, V> {
|
public class CollectionValueMap<K, V> extends AbsCollValueMap<K, V> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 9012989578038102983L;
|
private static final long serialVersionUID = 9012989578038102983L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值集合工厂方法
|
||||||
|
*/
|
||||||
private final SerSupplier<Collection<V>> collFactory;
|
private final SerSupplier<Collection<V>> collFactory;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------- Constructor start
|
// ------------------------------------------------------------------------- Constructor start
|
||||||
|
@ -20,6 +20,7 @@ import cn.hutool.v7.core.lang.ref.Ref;
|
|||||||
import cn.hutool.v7.core.lang.ref.ReferenceUtil;
|
import cn.hutool.v7.core.lang.ref.ReferenceUtil;
|
||||||
import cn.hutool.v7.core.map.MapUtil;
|
import cn.hutool.v7.core.map.MapUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
import java.lang.ref.ReferenceQueue;
|
import java.lang.ref.ReferenceQueue;
|
||||||
@ -37,10 +38,20 @@ import java.util.function.Function;
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public abstract class ReferenceConcurrentMap<K, V> implements ConcurrentMap<K, V>, Iterable<Map.Entry<K, V>>, Serializable {
|
public abstract class ReferenceConcurrentMap<K, V> implements ConcurrentMap<K, V>, Iterable<Map.Entry<K, V>>, Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 键值对引用
|
||||||
|
*/
|
||||||
final ConcurrentMap<Ref<K>, Ref<V>> raw;
|
final ConcurrentMap<Ref<K>, Ref<V>> raw;
|
||||||
|
/**
|
||||||
|
* 键队列
|
||||||
|
*/
|
||||||
private final ReferenceQueue<K> lastKeyQueue;
|
private final ReferenceQueue<K> lastKeyQueue;
|
||||||
|
/**
|
||||||
|
* 值队列
|
||||||
|
*/
|
||||||
private final ReferenceQueue<V> lastValueQueue;
|
private final ReferenceQueue<V> lastValueQueue;
|
||||||
/**
|
/**
|
||||||
* 回收监听
|
* 回收监听
|
||||||
|
@ -18,6 +18,7 @@ package cn.hutool.v7.core.math;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.array.ArrayUtil;
|
import cn.hutool.v7.core.array.ArrayUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -31,8 +32,12 @@ import java.util.List;
|
|||||||
* @since 4.0.7
|
* @since 4.0.7
|
||||||
*/
|
*/
|
||||||
public class Arrangement implements Serializable {
|
public class Arrangement implements Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于排列的数据
|
||||||
|
*/
|
||||||
private final String[] datas;
|
private final String[] datas;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ package cn.hutool.v7.core.math;
|
|||||||
|
|
||||||
import cn.hutool.v7.core.text.StrUtil;
|
import cn.hutool.v7.core.text.StrUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -31,8 +32,12 @@ import java.util.List;
|
|||||||
* @since 4.0.6
|
* @since 4.0.6
|
||||||
*/
|
*/
|
||||||
public class Combination implements Serializable {
|
public class Combination implements Serializable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于组合的数据
|
||||||
|
*/
|
||||||
private final String[] datas;
|
private final String[] datas;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,14 +16,15 @@
|
|||||||
|
|
||||||
package cn.hutool.v7.core.net.ssl;
|
package cn.hutool.v7.core.net.ssl;
|
||||||
|
|
||||||
import cn.hutool.v7.core.lang.builder.Builder;
|
|
||||||
import cn.hutool.v7.core.io.IORuntimeException;
|
|
||||||
import cn.hutool.v7.core.array.ArrayUtil;
|
import cn.hutool.v7.core.array.ArrayUtil;
|
||||||
|
import cn.hutool.v7.core.io.IORuntimeException;
|
||||||
|
import cn.hutool.v7.core.lang.builder.Builder;
|
||||||
import cn.hutool.v7.core.text.StrUtil;
|
import cn.hutool.v7.core.text.StrUtil;
|
||||||
|
|
||||||
import javax.net.ssl.KeyManager;
|
import javax.net.ssl.KeyManager;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
|
import java.io.Serial;
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
|
|
||||||
|
|
||||||
@ -42,12 +43,38 @@ import java.security.*;
|
|||||||
* @since 5.5.2
|
* @since 5.5.2
|
||||||
*/
|
*/
|
||||||
public class SSLContextBuilder implements SSLProtocols, Builder<SSLContext> {
|
public class SSLContextBuilder implements SSLProtocols, Builder<SSLContext> {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//SSL/TLS 协议配置参数
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用的 SSL/TLS 协议版本,默认为 TLS
|
||||||
|
*/
|
||||||
private String protocol = TLS;
|
private String protocol = TLS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密钥管理器数组,用于管理本地密钥材料(如客户端证书和私钥)
|
||||||
|
* 在建立安全连接时提供本地身份验证所需的密钥
|
||||||
|
*/
|
||||||
private KeyManager[] keyManagers;
|
private KeyManager[] keyManagers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 信任管理器数组,用于管理受信任的 CA 证书
|
||||||
|
* 决定哪些远程证书被视为可信(如服务器证书验证)
|
||||||
|
*/
|
||||||
private TrustManager[] trustManagers;
|
private TrustManager[] trustManagers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全随机数生成器,用于生成加密操作所需的高质量随机数
|
||||||
|
* 影响密钥生成、握手过程等安全性关键环节
|
||||||
|
*/
|
||||||
private SecureRandom secureRandom;
|
private SecureRandom secureRandom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全提供者,指定底层加密算法的实现提供者
|
||||||
|
* 如 Bouncy Castle、SunJSSE 等,影响可用算法和性能
|
||||||
|
*/
|
||||||
private Provider provider;
|
private Provider provider;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user