mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
91178e45a8
commit
6facfcfc4d
@ -214,10 +214,9 @@ public class HierarchicalAnnotatedElements implements AnnotatedElement, Iterable
|
|||||||
* @param <A> 注解类型
|
* @param <A> 注解类型
|
||||||
* @return 注解对象
|
* @return 注解对象
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public <A extends Annotation> A[] getDeclaredAnnotationsByType(final Class<A> annotationType) {
|
public <A extends Annotation> A[] getDeclaredAnnotationsByType(final Class<A> annotationType) {
|
||||||
return (A[]) getElementMappings().stream()
|
return getElementMappings().stream()
|
||||||
.map(element -> element.getDeclaredAnnotationsByType(annotationType))
|
.map(element -> element.getDeclaredAnnotationsByType(annotationType))
|
||||||
.filter(ArrayUtil::isNotEmpty)
|
.filter(ArrayUtil::isNotEmpty)
|
||||||
.flatMap(Stream::of)
|
.flatMap(Stream::of)
|
||||||
|
@ -15,7 +15,6 @@ package org.dromara.hutool.core.bean.copier;
|
|||||||
import org.dromara.hutool.core.bean.BeanUtil;
|
import org.dromara.hutool.core.bean.BeanUtil;
|
||||||
import org.dromara.hutool.core.bean.PropDesc;
|
import org.dromara.hutool.core.bean.PropDesc;
|
||||||
import org.dromara.hutool.core.lang.Assert;
|
import org.dromara.hutool.core.lang.Assert;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.lang.mutable.MutableEntry;
|
import org.dromara.hutool.core.lang.mutable.MutableEntry;
|
||||||
import org.dromara.hutool.core.map.CaseInsensitiveMap;
|
import org.dromara.hutool.core.map.CaseInsensitiveMap;
|
||||||
import org.dromara.hutool.core.map.MapWrapper;
|
import org.dromara.hutool.core.map.MapWrapper;
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.classloader;
|
package org.dromara.hutool.core.classloader;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
import org.dromara.hutool.core.exception.HutoolException;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.lang.caller.CallerUtil;
|
import org.dromara.hutool.core.lang.caller.CallerUtil;
|
||||||
import org.dromara.hutool.core.reflect.ClassDescUtil;
|
import org.dromara.hutool.core.reflect.ClassDescUtil;
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class Base64Decoder implements Decoder<byte[], byte[]>, Serializable {
|
|||||||
return octet;
|
return octet;
|
||||||
} else {
|
} else {
|
||||||
// 如果有非Base64字符混入,则实际结果比解析的要短,截取之
|
// 如果有非Base64字符混入,则实际结果比解析的要短,截取之
|
||||||
return (byte[]) ArrayUtil.copy(octet, new byte[octetId], octetId);
|
return ArrayUtil.copy(octet, new byte[octetId], octetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import org.dromara.hutool.core.comparator.PropertyComparator;
|
|||||||
import org.dromara.hutool.core.convert.CompositeConverter;
|
import org.dromara.hutool.core.convert.CompositeConverter;
|
||||||
import org.dromara.hutool.core.convert.Convert;
|
import org.dromara.hutool.core.convert.Convert;
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
import org.dromara.hutool.core.func.SerBiConsumer;
|
import org.dromara.hutool.core.func.SerBiConsumer;
|
||||||
import org.dromara.hutool.core.func.SerConsumer3;
|
import org.dromara.hutool.core.func.SerConsumer3;
|
||||||
import org.dromara.hutool.core.lang.Assert;
|
import org.dromara.hutool.core.lang.Assert;
|
||||||
|
@ -22,7 +22,7 @@ import java.util.Deque;
|
|||||||
public interface Linked<T extends Linked<T>> {
|
public interface Linked<T extends Linked<T>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the previous element or <tt>null</tt> if either the element is
|
* Retrieves the previous element or {@code null} if either the element is
|
||||||
* unlinked or the first element on the deque.
|
* unlinked or the first element on the deque.
|
||||||
*
|
*
|
||||||
* @return 前一个值
|
* @return 前一个值
|
||||||
@ -30,14 +30,14 @@ public interface Linked<T extends Linked<T>> {
|
|||||||
T getPrevious();
|
T getPrevious();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the previous element or <tt>null</tt> if there is no link.
|
* Sets the previous element or {@code null} if there is no link.
|
||||||
*
|
*
|
||||||
* @param prev 前一个值
|
* @param prev 前一个值
|
||||||
*/
|
*/
|
||||||
void setPrevious(T prev);
|
void setPrevious(T prev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the next element or <tt>null</tt> if either the element is
|
* Retrieves the next element or {@code null} if either the element is
|
||||||
* unlinked or the last element on the deque.
|
* unlinked or the last element on the deque.
|
||||||
*
|
*
|
||||||
* @return 下一个值
|
* @return 下一个值
|
||||||
@ -45,7 +45,7 @@ public interface Linked<T extends Linked<T>> {
|
|||||||
T getNext();
|
T getNext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the next element or <tt>null</tt> if there is no link.
|
* Sets the next element or {@code null} if there is no link.
|
||||||
*
|
*
|
||||||
* @param next 下一个值
|
* @param next 下一个值
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +20,7 @@ import java.util.*;
|
|||||||
* thread-safe; in the absence of external synchronization, they do not support
|
* thread-safe; in the absence of external synchronization, they do not support
|
||||||
* concurrent access by multiple threads. Null elements are prohibited.
|
* concurrent access by multiple threads. Null elements are prohibited.
|
||||||
* <p>
|
* <p>
|
||||||
* Most <tt>LinkedDeque</tt> operations run in constant time by assuming that
|
* Most <b>LinkedDeque</b> operations run in constant time by assuming that
|
||||||
* the {@link Linked} parameter is associated with the deque instance. Any usage
|
* the {@link Linked} parameter is associated with the deque instance. Any usage
|
||||||
* that violates this assumption will result in non-deterministic behavior.
|
* that violates this assumption will result in non-deterministic behavior.
|
||||||
* <p>
|
* <p>
|
||||||
@ -428,7 +428,7 @@ public class LinkedDeque<E extends Linked<E>> extends AbstractCollection<E> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the next element to traverse to or <tt>null</tt> if there are
|
* Retrieves the next element to traverse to or {@code null} if there are
|
||||||
* no more elements.
|
* no more elements.
|
||||||
*/
|
*/
|
||||||
abstract E computeNext();
|
abstract E computeNext();
|
||||||
|
@ -12,9 +12,7 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.convert;
|
package org.dromara.hutool.core.convert;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
import org.dromara.hutool.core.exception.HutoolException;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换异常
|
* 转换异常
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.convert;
|
package org.dromara.hutool.core.convert;
|
||||||
|
|
||||||
import org.dromara.hutool.core.convert.impl.*;
|
import org.dromara.hutool.core.convert.impl.*;
|
||||||
import org.dromara.hutool.core.date.DateTime;
|
|
||||||
import org.dromara.hutool.core.lang.Opt;
|
import org.dromara.hutool.core.lang.Opt;
|
||||||
import org.dromara.hutool.core.lang.tuple.Pair;
|
import org.dromara.hutool.core.lang.tuple.Pair;
|
||||||
import org.dromara.hutool.core.lang.tuple.Triple;
|
import org.dromara.hutool.core.lang.tuple.Triple;
|
||||||
|
@ -26,7 +26,7 @@ public class CurrencyConverter extends AbstractConverter {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Currency convertInternal(Class<?> targetClass, final Object value) {
|
protected Currency convertInternal(final Class<?> targetClass, final Object value) {
|
||||||
return Currency.getInstance(convertToStr(value));
|
return Currency.getInstance(convertToStr(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import org.dromara.hutool.core.bean.BeanUtil;
|
|||||||
import org.dromara.hutool.core.convert.CompositeConverter;
|
import org.dromara.hutool.core.convert.CompositeConverter;
|
||||||
import org.dromara.hutool.core.convert.ConvertException;
|
import org.dromara.hutool.core.convert.ConvertException;
|
||||||
import org.dromara.hutool.core.convert.Converter;
|
import org.dromara.hutool.core.convert.Converter;
|
||||||
import org.dromara.hutool.core.lang.tuple.Pair;
|
|
||||||
import org.dromara.hutool.core.lang.tuple.Triple;
|
import org.dromara.hutool.core.lang.tuple.Triple;
|
||||||
import org.dromara.hutool.core.reflect.TypeReference;
|
import org.dromara.hutool.core.reflect.TypeReference;
|
||||||
import org.dromara.hutool.core.reflect.TypeUtil;
|
import org.dromara.hutool.core.reflect.TypeUtil;
|
||||||
|
@ -194,7 +194,7 @@ public class BetweenFormatter implements Serializable {
|
|||||||
* @param simpleMode 是否简化模式
|
* @param simpleMode 是否简化模式
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public BetweenFormatter setSimpleMode(boolean simpleMode) {
|
public BetweenFormatter setSimpleMode(final boolean simpleMode) {
|
||||||
this.simpleMode = simpleMode;
|
this.simpleMode = simpleMode;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import java.time.temporal.ChronoField;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式化类,提供常用的日期格式化对象<br>
|
* 日期格式化类,提供常用的日期格式化对象<br>
|
||||||
|
@ -18,7 +18,7 @@ import org.dromara.hutool.core.date.DateTime;
|
|||||||
import org.dromara.hutool.core.date.DateUtil;
|
import org.dromara.hutool.core.date.DateUtil;
|
||||||
import org.dromara.hutool.core.date.TimeUtil;
|
import org.dromara.hutool.core.date.TimeUtil;
|
||||||
import org.dromara.hutool.core.date.Zodiac;
|
import org.dromara.hutool.core.date.Zodiac;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
import org.dromara.hutool.core.lang.Assert;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
import org.dromara.hutool.core.text.StrUtil;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@ -62,7 +62,7 @@ public class ChineseDate {
|
|||||||
* @param date 公历日期
|
* @param date 公历日期
|
||||||
*/
|
*/
|
||||||
public ChineseDate(final Date date) {
|
public ChineseDate(final Date date) {
|
||||||
this(TimeUtil.ofDate(date.toInstant()));
|
this(TimeUtil.ofDate(Assert.notNull(date.toInstant())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,6 @@ import org.dromara.hutool.core.date.format.parser.PositionDateParser;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.FieldPosition;
|
import java.text.FieldPosition;
|
||||||
import java.text.Format;
|
import java.text.Format;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
@ -506,7 +506,7 @@ public class FastDatePrinter extends SimpleDateBasic implements DatePrinter {
|
|||||||
/**
|
/**
|
||||||
* 规则
|
* 规则
|
||||||
*/
|
*/
|
||||||
private interface Rule {
|
public interface Rule {
|
||||||
/**
|
/**
|
||||||
* Returns the estimated length of the result.
|
* Returns the estimated length of the result.
|
||||||
*
|
*
|
||||||
@ -529,7 +529,7 @@ public class FastDatePrinter extends SimpleDateBasic implements DatePrinter {
|
|||||||
* Inner class defining a numeric rule.
|
* Inner class defining a numeric rule.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
private interface NumberRule extends Rule {
|
public interface NumberRule extends Rule {
|
||||||
/**
|
/**
|
||||||
* Appends the specified value to the output buffer based on the rule implementation.
|
* Appends the specified value to the output buffer based on the rule implementation.
|
||||||
*
|
*
|
||||||
|
@ -15,7 +15,6 @@ package org.dromara.hutool.core.date.format.parser;
|
|||||||
import org.dromara.hutool.core.date.DateException;
|
import org.dromara.hutool.core.date.DateException;
|
||||||
import org.dromara.hutool.core.date.format.DateBasic;
|
import org.dromara.hutool.core.date.format.DateBasic;
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,6 @@ import org.dromara.hutool.core.date.DateException;
|
|||||||
import org.dromara.hutool.core.date.DatePattern;
|
import org.dromara.hutool.core.date.DatePattern;
|
||||||
import org.dromara.hutool.core.date.DateTime;
|
import org.dromara.hutool.core.date.DateTime;
|
||||||
import org.dromara.hutool.core.date.format.DefaultDateBasic;
|
import org.dromara.hutool.core.date.format.DefaultDateBasic;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.regex.ReUtil;
|
import org.dromara.hutool.core.regex.ReUtil;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
import org.dromara.hutool.core.text.StrUtil;
|
||||||
import org.dromara.hutool.core.text.CharUtil;
|
import org.dromara.hutool.core.text.CharUtil;
|
||||||
|
@ -16,7 +16,6 @@ import org.dromara.hutool.core.date.DateException;
|
|||||||
import org.dromara.hutool.core.date.DatePattern;
|
import org.dromara.hutool.core.date.DatePattern;
|
||||||
import org.dromara.hutool.core.date.DateTime;
|
import org.dromara.hutool.core.date.DateTime;
|
||||||
import org.dromara.hutool.core.date.format.DefaultDateBasic;
|
import org.dromara.hutool.core.date.format.DefaultDateBasic;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.regex.ReUtil;
|
import org.dromara.hutool.core.regex.ReUtil;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
import org.dromara.hutool.core.text.StrUtil;
|
||||||
import org.dromara.hutool.core.text.CharUtil;
|
import org.dromara.hutool.core.text.CharUtil;
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.io.buffer;
|
package org.dromara.hutool.core.io.buffer;
|
||||||
|
|
||||||
import org.dromara.hutool.core.io.IORuntimeException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码移植自<a href="https://github.com/biezhi/blade">blade</a><br>
|
* 代码移植自<a href="https://github.com/biezhi/blade">blade</a><br>
|
||||||
* 快速缓冲,将数据存放在缓冲集中,取代以往的单一数组
|
* 快速缓冲,将数据存放在缓冲集中,取代以往的单一数组
|
||||||
|
@ -42,7 +42,6 @@ import java.net.URLConnection;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -19,7 +19,6 @@ import org.dromara.hutool.core.func.SerConsumer;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.WatchEvent;
|
import java.nio.file.WatchEvent;
|
||||||
import java.nio.file.WatchKey;
|
import java.nio.file.WatchKey;
|
||||||
|
|
||||||
|
@ -157,6 +157,8 @@ public class Tailer implements Serializable {
|
|||||||
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(){
|
||||||
|
private static final long serialVersionUID = 4497160994840060329L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDelete(final WatchEvent<?> event, final WatchKey key) {
|
public void onDelete(final WatchEvent<?> event, final WatchKey key) {
|
||||||
super.onDelete(event, key);
|
super.onDelete(event, key);
|
||||||
|
@ -113,7 +113,7 @@ public abstract class TransMap<K, V> extends MapWrapper<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public V putIfAbsent(K key, V value) {
|
public V putIfAbsent(final K key, final V value) {
|
||||||
return super.putIfAbsent(customKey(key), customValue(value));
|
return super.putIfAbsent(customKey(key), customValue(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public interface TreeEntry<K, V> extends Map.Entry<K, V> {
|
|||||||
* @param key 指定父节点的key
|
* @param key 指定父节点的key
|
||||||
* @return 是否
|
* @return 是否
|
||||||
*/
|
*/
|
||||||
default boolean containsParent(K key) {
|
default boolean containsParent(final K key) {
|
||||||
return ObjUtil.isNotNull(getParent(key));
|
return ObjUtil.isNotNull(getParent(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public interface TreeEntry<K, V> extends Map.Entry<K, V> {
|
|||||||
* @param key 指定子节点的key
|
* @param key 指定子节点的key
|
||||||
* @return 是否
|
* @return 是否
|
||||||
*/
|
*/
|
||||||
default boolean containsChild(K key) {
|
default boolean containsChild(final K key) {
|
||||||
return ObjUtil.isNotNull(getChild(key));
|
return ObjUtil.isNotNull(getChild(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,7 +1588,7 @@ public final class ConcurrentLinkedHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
*/
|
*/
|
||||||
public Builder<K, V> weigher(final Weigher<? super V> weigher) {
|
public Builder<K, V> weigher(final Weigher<? super V> weigher) {
|
||||||
this.weigher = (weigher == Weighers.singleton())
|
this.weigher = (weigher == Weighers.singleton())
|
||||||
? Weighers.<K, V>entrySingleton()
|
? Weighers.entrySingleton()
|
||||||
: new BoundedEntryWeigher<>(Weighers.asEntryWeigher(weigher));
|
: new BoundedEntryWeigher<>(Weighers.asEntryWeigher(weigher));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,12 @@ public final class Weighers {
|
|||||||
public static <K, V> EntryWeigher<K, V> asEntryWeigher(
|
public static <K, V> EntryWeigher<K, V> asEntryWeigher(
|
||||||
final Weigher<? super V> weigher) {
|
final Weigher<? super V> weigher) {
|
||||||
return (weigher == singleton())
|
return (weigher == singleton())
|
||||||
? Weighers.<K, V>entrySingleton()
|
? Weighers.entrySingleton()
|
||||||
: new EntryWeigherView<K, V>(weigher);
|
: new EntryWeigherView<K, V>(weigher);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A weigher where an entry has a selector of <tt>1</tt>. A map bounded with
|
* A weigher where an entry has a selector of <b>1</b>. A map bounded with
|
||||||
* this weigher will evict when the number of key-value pairs exceeds the
|
* this weigher will evict when the number of key-value pairs exceeds the
|
||||||
* capacity.
|
* capacity.
|
||||||
*
|
*
|
||||||
@ -64,7 +64,7 @@ public final class Weighers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A weigher where a value has a selector of <tt>1</tt>. A map bounded with
|
* A weigher where a value has a selector of <b>1</b>. A map bounded with
|
||||||
* this weigher will evict when the number of key-value pairs exceeds the
|
* this weigher will evict when the number of key-value pairs exceeds the
|
||||||
* capacity.
|
* capacity.
|
||||||
*
|
*
|
||||||
@ -84,7 +84,7 @@ public final class Weighers {
|
|||||||
* and is primarily for usage by dedicated caching servers that hold the
|
* and is primarily for usage by dedicated caching servers that hold the
|
||||||
* serialized data.
|
* serialized data.
|
||||||
* <p>
|
* <p>
|
||||||
* A value with a selector of <tt>0</tt> will be rejected by the map. If a value
|
* A value with a selector of <b>0</b> will be rejected by the map. If a value
|
||||||
* with this selector can occur then the caller should eagerly evaluate the
|
* with this selector can occur then the caller should eagerly evaluate the
|
||||||
* value and treat it as a removal operation. Alternatively, a custom weigher
|
* value and treat it as a removal operation. Alternatively, a custom weigher
|
||||||
* may be specified on the map to assign an empty value a positive selector.
|
* may be specified on the map to assign an empty value a positive selector.
|
||||||
@ -102,7 +102,7 @@ public final class Weighers {
|
|||||||
* map bounded with this weigher will evict when the total number of elements
|
* map bounded with this weigher will evict when the total number of elements
|
||||||
* exceeds the capacity rather than the number of key-value pairs in the map.
|
* exceeds the capacity rather than the number of key-value pairs in the map.
|
||||||
* <p>
|
* <p>
|
||||||
* A value with a selector of <tt>0</tt> will be rejected by the map. If a value
|
* A value with a selector of <b>0</b> will be rejected by the map. If a value
|
||||||
* with this selector can occur then the caller should eagerly evaluate the
|
* with this selector can occur then the caller should eagerly evaluate the
|
||||||
* value and treat it as a removal operation. Alternatively, a custom weigher
|
* value and treat it as a removal operation. Alternatively, a custom weigher
|
||||||
* may be specified on the map to assign an empty value a positive selector.
|
* may be specified on the map to assign an empty value a positive selector.
|
||||||
@ -110,9 +110,8 @@ public final class Weighers {
|
|||||||
* @param <E> 元素类型
|
* @param <E> 元素类型
|
||||||
* @return A weigher where each element takes one unit of capacity.
|
* @return A weigher where each element takes one unit of capacity.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"cast", "unchecked"})
|
|
||||||
public static <E> Weigher<? super Iterable<E>> iterable() {
|
public static <E> Weigher<? super Iterable<E>> iterable() {
|
||||||
return (Weigher<Iterable<E>>) (Weigher<?>) IterableWeigher.INSTANCE;
|
return IterableWeigher.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,7 +120,7 @@ public final class Weighers {
|
|||||||
* total number of elements exceeds the capacity rather than the number of
|
* total number of elements exceeds the capacity rather than the number of
|
||||||
* key-value pairs in the map.
|
* key-value pairs in the map.
|
||||||
* <p>
|
* <p>
|
||||||
* A value with a selector of <tt>0</tt> will be rejected by the map. If a value
|
* A value with a selector of <b>0</b> will be rejected by the map. If a value
|
||||||
* with this selector can occur then the caller should eagerly evaluate the
|
* with this selector can occur then the caller should eagerly evaluate the
|
||||||
* value and treat it as a removal operation. Alternatively, a custom weigher
|
* value and treat it as a removal operation. Alternatively, a custom weigher
|
||||||
* may be specified on the map to assign an empty value a positive selector.
|
* may be specified on the map to assign an empty value a positive selector.
|
||||||
@ -129,9 +128,8 @@ public final class Weighers {
|
|||||||
* @param <E> 元素类型
|
* @param <E> 元素类型
|
||||||
* @return A weigher where each element takes one unit of capacity.
|
* @return A weigher where each element takes one unit of capacity.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"cast", "unchecked"})
|
|
||||||
public static <E> Weigher<? super Collection<E>> collection() {
|
public static <E> Weigher<? super Collection<E>> collection() {
|
||||||
return (Weigher<Collection<E>>) (Weigher<?>) CollectionWeigher.INSTANCE;
|
return CollectionWeigher.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,7 +138,7 @@ public final class Weighers {
|
|||||||
* number of elements exceeds the capacity rather than the number of
|
* number of elements exceeds the capacity rather than the number of
|
||||||
* key-value pairs in the map.
|
* key-value pairs in the map.
|
||||||
* <p>
|
* <p>
|
||||||
* A value with a selector of <tt>0</tt> will be rejected by the map. If a value
|
* A value with a selector of <b>0</b> will be rejected by the map. If a value
|
||||||
* with this selector can occur then the caller should eagerly evaluate the
|
* with this selector can occur then the caller should eagerly evaluate the
|
||||||
* value and treat it as a removal operation. Alternatively, a custom weigher
|
* value and treat it as a removal operation. Alternatively, a custom weigher
|
||||||
* may be specified on the map to assign an empty value a positive selector.
|
* may be specified on the map to assign an empty value a positive selector.
|
||||||
@ -159,7 +157,7 @@ public final class Weighers {
|
|||||||
* number of elements exceeds the capacity rather than the number of
|
* number of elements exceeds the capacity rather than the number of
|
||||||
* key-value pairs in the map.
|
* key-value pairs in the map.
|
||||||
* <p>
|
* <p>
|
||||||
* A value with a selector of <tt>0</tt> will be rejected by the map. If a value
|
* A value with a selector of <b>0</b> will be rejected by the map. If a value
|
||||||
* with this selector can occur then the caller should eagerly evaluate the
|
* with this selector can occur then the caller should eagerly evaluate the
|
||||||
* value and treat it as a removal operation. Alternatively, a custom weigher
|
* value and treat it as a removal operation. Alternatively, a custom weigher
|
||||||
* may be specified on the map to assign an empty value a positive selector.
|
* may be specified on the map to assign an empty value a positive selector.
|
||||||
@ -178,7 +176,7 @@ public final class Weighers {
|
|||||||
* entries across all values exceeds the capacity rather than the number of
|
* entries across all values exceeds the capacity rather than the number of
|
||||||
* key-value pairs in the map.
|
* key-value pairs in the map.
|
||||||
* <p>
|
* <p>
|
||||||
* A value with a selector of <tt>0</tt> will be rejected by the map. If a value
|
* A value with a selector of <b>0</b> will be rejected by the map. If a value
|
||||||
* with this selector can occur then the caller should eagerly evaluate the
|
* with this selector can occur then the caller should eagerly evaluate the
|
||||||
* value and treat it as a removal operation. Alternatively, a custom weigher
|
* value and treat it as a removal operation. Alternatively, a custom weigher
|
||||||
* may be specified on the map to assign an empty value a positive selector.
|
* may be specified on the map to assign an empty value a positive selector.
|
||||||
|
@ -44,7 +44,7 @@ public class CollectionValueMap<K, V> extends AbsCollValueMap<K, V> {
|
|||||||
* @param mapFactory 生成集合的工厂方法
|
* @param mapFactory 生成集合的工厂方法
|
||||||
* @param collFactory 生成值集合的工厂方法
|
* @param collFactory 生成值集合的工厂方法
|
||||||
*/
|
*/
|
||||||
public CollectionValueMap(Supplier<Map<K, Collection<V>>> mapFactory, SerSupplier<Collection<V>> collFactory) {
|
public CollectionValueMap(final Supplier<Map<K, Collection<V>>> mapFactory, final SerSupplier<Collection<V>> collFactory) {
|
||||||
super(mapFactory);
|
super(mapFactory);
|
||||||
this.collFactory = collFactory;
|
this.collFactory = collFactory;
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ public class CollectionValueMap<K, V> extends AbsCollValueMap<K, V> {
|
|||||||
*
|
*
|
||||||
* @param collFactory 生成值集合的工厂方法
|
* @param collFactory 生成值集合的工厂方法
|
||||||
*/
|
*/
|
||||||
public CollectionValueMap(SerSupplier<Collection<V>> collFactory) {
|
public CollectionValueMap(final SerSupplier<Collection<V>> collFactory) {
|
||||||
this.collFactory = collFactory;
|
this.collFactory = collFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public class CollectionValueMap<K, V> extends AbsCollValueMap<K, V> {
|
|||||||
*
|
*
|
||||||
* @param map 提供数据的原始集合
|
* @param map 提供数据的原始集合
|
||||||
*/
|
*/
|
||||||
public CollectionValueMap(Map<K, Collection<V>> map) {
|
public CollectionValueMap(final Map<K, Collection<V>> map) {
|
||||||
super(map);
|
super(map);
|
||||||
this.collFactory = ArrayList::new;
|
this.collFactory = ArrayList::new;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ public interface MultiValueMap<K, V> extends Map<K, Collection<V>> {
|
|||||||
* @param filter 判断方法
|
* @param filter 判断方法
|
||||||
* @return 当前实例
|
* @return 当前实例
|
||||||
*/
|
*/
|
||||||
default MultiValueMap<K, V> filterAllValues(Predicate<V> filter) {
|
default MultiValueMap<K, V> filterAllValues(final Predicate<V> filter) {
|
||||||
return filterAllValues((k, v) -> filter.test(v));
|
return filterAllValues((k, v) -> filter.test(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ public interface MultiValueMap<K, V> extends Map<K, Collection<V>> {
|
|||||||
* @param operate 替换方法
|
* @param operate 替换方法
|
||||||
* @return 当前实例
|
* @return 当前实例
|
||||||
*/
|
*/
|
||||||
default MultiValueMap<K, V> replaceAllValues(UnaryOperator<V> operate) {
|
default MultiValueMap<K, V> replaceAllValues(final UnaryOperator<V> operate) {
|
||||||
return replaceAllValues((k, v) -> operate.apply(v));
|
return replaceAllValues((k, v) -> operate.apply(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ public interface MultiValueMap<K, V> extends Map<K, Collection<V>> {
|
|||||||
* @param index 第几个值的索引,越界返回null
|
* @param index 第几个值的索引,越界返回null
|
||||||
* @return 值或null
|
* @return 值或null
|
||||||
*/
|
*/
|
||||||
default V getValue(K key, int index) {
|
default V getValue(final K key, final int index) {
|
||||||
final Collection<V> collection = get(key);
|
final Collection<V> collection = get(key);
|
||||||
return CollUtil.get(collection, index);
|
return CollUtil.get(collection, index);
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ public interface MultiValueMap<K, V> extends Map<K, Collection<V>> {
|
|||||||
*
|
*
|
||||||
* @param consumer 操作
|
* @param consumer 操作
|
||||||
*/
|
*/
|
||||||
default void allForEach(BiConsumer<K, V> consumer) {
|
default void allForEach(final BiConsumer<K, V> consumer) {
|
||||||
forEach((k, coll) -> coll.forEach(v -> consumer.accept(k, v)));
|
forEach((k, coll) -> coll.forEach(v -> consumer.accept(k, v)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class SetValueMap<K, V> extends AbsCollValueMap<K, V> {
|
|||||||
*
|
*
|
||||||
* @param mapFactory 创建集合的工厂反方
|
* @param mapFactory 创建集合的工厂反方
|
||||||
*/
|
*/
|
||||||
public SetValueMap(Supplier<Map<K, Collection<V>>> mapFactory) {
|
public SetValueMap(final Supplier<Map<K, Collection<V>>> mapFactory) {
|
||||||
super(mapFactory);
|
super(mapFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public class SetValueMap<K, V> extends AbsCollValueMap<K, V> {
|
|||||||
*
|
*
|
||||||
* @param map 提供数据的原始集合
|
* @param map 提供数据的原始集合
|
||||||
*/
|
*/
|
||||||
public SetValueMap(Map<K, Collection<V>> map) {
|
public SetValueMap(final Map<K, Collection<V>> map) {
|
||||||
super(map);
|
super(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,6 +454,6 @@ public class UrlQuery {
|
|||||||
/**
|
/**
|
||||||
* 严格模式,此模式下,非UNRESERVED的字符都会被转义
|
* 严格模式,此模式下,非UNRESERVED的字符都会被转义
|
||||||
*/
|
*/
|
||||||
STRICT;
|
STRICT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ public class ConstructorLookupFactory implements LookupFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("JavaReflectionMemberAccess")
|
||||||
private static Constructor<MethodHandles.Lookup> createLookupConstructor() {
|
private static Constructor<MethodHandles.Lookup> createLookupConstructor() {
|
||||||
final Constructor<MethodHandles.Lookup> constructor;
|
final Constructor<MethodHandles.Lookup> constructor;
|
||||||
try {
|
try {
|
||||||
|
@ -2032,7 +2032,7 @@ public class CharSequenceUtil extends StrValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 给定字符串是否与提供的中任一字符串相同(忽略大小写),相同则返回{@code true},没有相同的返回{@code false}<br>
|
* 给定字符串是否与提供的中任意一个字符串相同(忽略大小写),相同则返回{@code true},没有相同的返回{@code false}<br>
|
||||||
* 如果参与比对的字符串列表为空,返回{@code false}
|
* 如果参与比对的字符串列表为空,返回{@code false}
|
||||||
*
|
*
|
||||||
* @param str1 给定需要检查的字符串
|
* @param str1 给定需要检查的字符串
|
||||||
@ -2831,7 +2831,7 @@ public class CharSequenceUtil extends StrValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果给定字符串不是以给定的一个或多个字符串为开头,则在首部添加起始字符串<br>
|
* 如果给定字符串不是以给定的一个或多个字符串为开头,则在前面添加起始字符串<br>
|
||||||
* 不忽略大小写
|
* 不忽略大小写
|
||||||
*
|
*
|
||||||
* @param str 被检查的字符串
|
* @param str 被检查的字符串
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.text;
|
package org.dromara.hutool.core.text;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串或字符重复器<br>
|
* 字符串或字符重复器<br>
|
||||||
* 用于将给定字符串或字符赋值count次,然后拼接
|
* 用于将给定字符串或字符赋值count次,然后拼接
|
||||||
@ -60,9 +62,7 @@ public class StrRepeater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final char[] result = new char[count];
|
final char[] result = new char[count];
|
||||||
for (int i = 0; i < count; i++) {
|
Arrays.fill(result, c);
|
||||||
result[i] = c;
|
|
||||||
}
|
|
||||||
return new String(result);
|
return new String(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,6 @@ public class StrTrimer implements UnaryOperator<CharSequence>, Serializable {
|
|||||||
/**
|
/**
|
||||||
* 字符串两边
|
* 字符串两边
|
||||||
*/
|
*/
|
||||||
BOTH;
|
BOTH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,7 @@ public class NFA {
|
|||||||
needBuildAc = true;
|
needBuildAc = true;
|
||||||
Node p = root;
|
Node p = root;
|
||||||
for (final char curr : word.toCharArray()) {
|
for (final char curr : word.toCharArray()) {
|
||||||
if (p.next.get((int) curr) == null) {
|
p.next.computeIfAbsent((int) curr, k -> new Node());
|
||||||
p.next.put((int) curr, new Node());
|
|
||||||
}
|
|
||||||
p = p.next.get((int) curr);
|
p = p.next.get((int) curr);
|
||||||
}
|
}
|
||||||
p.flag = true;
|
p.flag = true;
|
||||||
|
@ -118,7 +118,7 @@ public class AsyncUtil {
|
|||||||
* @param eHandler 异常处理方法
|
* @param eHandler 异常处理方法
|
||||||
* @return 任务结果集合
|
* @return 任务结果集合
|
||||||
*/
|
*/
|
||||||
public static <T> List<T> allOfGet(final CompletableFuture<T>[] tasks, Function<Exception, T> eHandler) {
|
public static <T> List<T> allOfGet(final CompletableFuture<T>[] tasks, final Function<Exception, T> eHandler) {
|
||||||
Assert.notEmpty(tasks);
|
Assert.notEmpty(tasks);
|
||||||
|
|
||||||
return allOfGet(Arrays.asList(tasks), eHandler);
|
return allOfGet(Arrays.asList(tasks), eHandler);
|
||||||
@ -132,7 +132,7 @@ public class AsyncUtil {
|
|||||||
* @param eHandler 异常处理方法
|
* @param eHandler 异常处理方法
|
||||||
* @return 任务结果集合
|
* @return 任务结果集合
|
||||||
*/
|
*/
|
||||||
public static <T> List<T> allOfGet(final List<CompletableFuture<T>> tasks, Function<Exception, T> eHandler) {
|
public static <T> List<T> allOfGet(final List<CompletableFuture<T>> tasks, final Function<Exception, T> eHandler) {
|
||||||
Assert.notEmpty(tasks);
|
Assert.notEmpty(tasks);
|
||||||
|
|
||||||
return execute(tasks, eHandler, false);
|
return execute(tasks, eHandler, false);
|
||||||
@ -174,7 +174,7 @@ public class AsyncUtil {
|
|||||||
* @param eHandler 异常处理方法
|
* @param eHandler 异常处理方法
|
||||||
* @return 任务结果集合
|
* @return 任务结果集合
|
||||||
*/
|
*/
|
||||||
public static <T> List<T> parallelAllOfGet(final CompletableFuture<T>[] tasks, Function<Exception, T> eHandler) {
|
public static <T> List<T> parallelAllOfGet(final CompletableFuture<T>[] tasks, final Function<Exception, T> eHandler) {
|
||||||
Assert.notEmpty(tasks);
|
Assert.notEmpty(tasks);
|
||||||
|
|
||||||
return parallelAllOfGet(Arrays.asList(tasks), eHandler);
|
return parallelAllOfGet(Arrays.asList(tasks), eHandler);
|
||||||
@ -188,7 +188,7 @@ public class AsyncUtil {
|
|||||||
* @param eHandler 异常处理方法
|
* @param eHandler 异常处理方法
|
||||||
* @return 任务结果集合
|
* @return 任务结果集合
|
||||||
*/
|
*/
|
||||||
public static <T> List<T> parallelAllOfGet(final List<CompletableFuture<T>> tasks, Function<Exception, T> eHandler) {
|
public static <T> List<T> parallelAllOfGet(final List<CompletableFuture<T>> tasks, final Function<Exception, T> eHandler) {
|
||||||
Assert.notEmpty(tasks);
|
Assert.notEmpty(tasks);
|
||||||
|
|
||||||
return execute(tasks, eHandler, true);
|
return execute(tasks, eHandler, true);
|
||||||
@ -203,12 +203,12 @@ public class AsyncUtil {
|
|||||||
* @param isParallel 是否是并行 {@link Stream}
|
* @param isParallel 是否是并行 {@link Stream}
|
||||||
* @return 任务结果集合
|
* @return 任务结果集合
|
||||||
*/
|
*/
|
||||||
private static <T> List<T> execute(List<CompletableFuture<T>> tasks, Function<Exception, T> eHandler, boolean isParallel) {
|
private static <T> List<T> execute(final List<CompletableFuture<T>> tasks, final Function<Exception, T> eHandler, final boolean isParallel) {
|
||||||
return StreamUtil.of(tasks, isParallel)
|
return StreamUtil.of(tasks, isParallel)
|
||||||
.map(e -> {
|
.map(e -> {
|
||||||
try {
|
try {
|
||||||
return e.get();
|
return e.get();
|
||||||
} catch (InterruptedException | ExecutionException ex) {
|
} catch (final InterruptedException | ExecutionException ex) {
|
||||||
if (eHandler != null) {
|
if (eHandler != null) {
|
||||||
return eHandler.apply(ex);
|
return eHandler.apply(ex);
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,7 +57,7 @@ public class BlockPolicy implements RejectedExecutionHandler {
|
|||||||
if (!e.isShutdown()) {
|
if (!e.isShutdown()) {
|
||||||
try {
|
try {
|
||||||
e.getQueue().put(r);
|
e.getQueue().put(r);
|
||||||
} catch (InterruptedException ex) {
|
} catch (final InterruptedException ex) {
|
||||||
throw new RejectedExecutionException("Task " + r + " rejected from " + e);
|
throw new RejectedExecutionException("Task " + r + " rejected from " + e);
|
||||||
}
|
}
|
||||||
} else if (null != handlerwhenshutdown) {
|
} else if (null != handlerwhenshutdown) {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.thread;
|
package org.dromara.hutool.core.thread;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
import org.dromara.hutool.core.exception.HutoolException;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -12,20 +12,16 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.classloader;
|
package org.dromara.hutool.core.classloader;
|
||||||
|
|
||||||
import org.dromara.hutool.core.collection.iter.EnumerationIter;
|
|
||||||
import org.dromara.hutool.core.io.file.FileUtil;
|
import org.dromara.hutool.core.io.file.FileUtil;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
import org.dromara.hutool.core.lang.Console;
|
||||||
import org.dromara.hutool.core.map.Dict;
|
import org.dromara.hutool.core.map.Dict;
|
||||||
import org.dromara.hutool.core.reflect.ClassUtil;
|
import org.dromara.hutool.core.reflect.ClassUtil;
|
||||||
import org.dromara.hutool.core.reflect.FieldUtil;
|
import org.dromara.hutool.core.reflect.FieldUtil;
|
||||||
import org.dromara.hutool.core.reflect.method.MethodUtil;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.sql.Driver;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
|
|
||||||
public class ClassLoaderUtilTest {
|
public class ClassLoaderUtilTest {
|
||||||
|
|
||||||
|
@ -532,8 +532,8 @@ public class CollUtilTest {
|
|||||||
final List<Object> list1 = ListUtil.of(false);
|
final List<Object> list1 = ListUtil.of(false);
|
||||||
final List<Object> list2 = ListUtil.of(true);
|
final List<Object> list2 = ListUtil.of(true);
|
||||||
|
|
||||||
Assertions.assertTrue(list1 instanceof ArrayList);
|
Assertions.assertInstanceOf(ArrayList.class, list1);
|
||||||
Assertions.assertTrue(list2 instanceof LinkedList);
|
Assertions.assertInstanceOf(LinkedList.class, list2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -22,15 +22,15 @@ public class ArrayIterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasNext() {
|
public void testHasNext() {
|
||||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||||
Assertions.assertTrue(iter.hasNext());
|
Assertions.assertTrue(iter.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNext() {
|
public void testNext() {
|
||||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||||
Assertions.assertEquals((Integer)1, iter.next());
|
Assertions.assertEquals((Integer)1, iter.next());
|
||||||
Assertions.assertEquals((Integer)2, iter.next());
|
Assertions.assertEquals((Integer)2, iter.next());
|
||||||
Assertions.assertEquals((Integer)3, iter.next());
|
Assertions.assertEquals((Integer)3, iter.next());
|
||||||
@ -38,22 +38,22 @@ public class ArrayIterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemove() {
|
public void testRemove() {
|
||||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||||
Assertions.assertThrows(UnsupportedOperationException.class, iter::remove);
|
Assertions.assertThrows(UnsupportedOperationException.class, iter::remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetArray() {
|
public void testGetArray() {
|
||||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||||
Assertions.assertEquals(arr, iter.getArray());
|
Assertions.assertEquals(arr, iter.getArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReset() {
|
public void testReset() {
|
||||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||||
Assertions.assertEquals((Integer)1, iter.next());
|
Assertions.assertEquals((Integer)1, iter.next());
|
||||||
iter.reset();
|
iter.reset();
|
||||||
Assertions.assertEquals((Integer)1, iter.next());
|
Assertions.assertEquals((Integer)1, iter.next());
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.collection.iter;
|
package org.dromara.hutool.core.collection.iter;
|
||||||
|
|
||||||
|
import org.dromara.hutool.core.exception.HutoolException;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@ -27,13 +28,13 @@ public class LineIterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasNext() {
|
public void testHasNext() {
|
||||||
LineIter iter = getItrFromClasspathFile();
|
final LineIter iter = getItrFromClasspathFile();
|
||||||
Assertions.assertTrue(iter.hasNext());
|
Assertions.assertTrue(iter.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNext() {
|
public void testNext() {
|
||||||
LineIter iter = getItrFromClasspathFile();
|
final LineIter iter = getItrFromClasspathFile();
|
||||||
Assertions.assertEquals("is first line", iter.next());
|
Assertions.assertEquals("is first line", iter.next());
|
||||||
Assertions.assertEquals("is second line", iter.next());
|
Assertions.assertEquals("is second line", iter.next());
|
||||||
Assertions.assertEquals("is third line", iter.next());
|
Assertions.assertEquals("is third line", iter.next());
|
||||||
@ -41,39 +42,39 @@ public class LineIterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemove() {
|
public void testRemove() {
|
||||||
LineIter iter = getItrFromClasspathFile();
|
final LineIter iter = getItrFromClasspathFile();
|
||||||
iter.next();
|
iter.next();
|
||||||
Assertions.assertThrows(UnsupportedOperationException.class, iter::remove);
|
Assertions.assertThrows(UnsupportedOperationException.class, iter::remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFinish() {
|
public void testFinish() {
|
||||||
LineIter iter = getItrFromClasspathFile();
|
final LineIter iter = getItrFromClasspathFile();
|
||||||
iter.finish();
|
iter.finish();
|
||||||
Assertions.assertThrows(NoSuchElementException.class, iter::next);
|
Assertions.assertThrows(NoSuchElementException.class, iter::next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClose() throws IOException {
|
public void testClose() throws IOException {
|
||||||
URL url = LineIterTest.class.getClassLoader().getResource("text.txt");
|
final URL url = LineIterTest.class.getClassLoader().getResource("text.txt");
|
||||||
Assertions.assertNotNull(url);
|
Assertions.assertNotNull(url);
|
||||||
FileInputStream inputStream = new FileInputStream(url.getFile());
|
final FileInputStream inputStream = new FileInputStream(url.getFile());
|
||||||
LineIter iter = new LineIter(inputStream, StandardCharsets.UTF_8);
|
final LineIter iter = new LineIter(inputStream, StandardCharsets.UTF_8);
|
||||||
iter.close();
|
iter.close();
|
||||||
Assertions.assertThrows(NoSuchElementException.class, iter::next);
|
Assertions.assertThrows(NoSuchElementException.class, iter::next);
|
||||||
Assertions.assertThrows(IOException.class, inputStream::read);
|
Assertions.assertThrows(IOException.class, inputStream::read);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LineIter getItrFromClasspathFile() {
|
private static LineIter getItrFromClasspathFile() {
|
||||||
URL url = LineIterTest.class.getClassLoader().getResource("text.txt");
|
final URL url = LineIterTest.class.getClassLoader().getResource("text.txt");
|
||||||
Assertions.assertNotNull(url);
|
Assertions.assertNotNull(url);
|
||||||
FileInputStream inputStream = null;
|
final FileInputStream inputStream;
|
||||||
try {
|
try {
|
||||||
inputStream = new FileInputStream(url.getFile());
|
inputStream = new FileInputStream(url.getFile());
|
||||||
} catch (FileNotFoundException e) {
|
} catch (final FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
throw new HutoolException(e);
|
||||||
}
|
}
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
return new LineIter(bufferedReader);
|
return new LineIter(bufferedReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,32 +27,32 @@ import java.util.Set;
|
|||||||
public class CastUtilTest {
|
public class CastUtilTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCastToSuper() {
|
public void testCastToSuper() {
|
||||||
Collection<Integer> collection= ListUtil.of(1,2,3);
|
final Collection<Integer> collection= ListUtil.of(1,2,3);
|
||||||
List<Integer> list = ListUtil.of(1, 2, 3);
|
final List<Integer> list = ListUtil.of(1, 2, 3);
|
||||||
Set<Integer> set = SetUtil.of(1, 2, 3);
|
final Set<Integer> set = SetUtil.of(1, 2, 3);
|
||||||
Map<Integer, Integer> map = new HashMap<>();
|
final Map<Integer, Integer> map = new HashMap<>();
|
||||||
map.put(1, 1);
|
map.put(1, 1);
|
||||||
|
|
||||||
Collection<Number> collection2 = CastUtil.castUp(collection);
|
final Collection<Number> collection2 = CastUtil.castUp(collection);
|
||||||
collection2.add(new Double("123.1"));
|
collection2.add(new Double("123.1"));
|
||||||
Assertions.assertSame(collection, collection2);
|
Assertions.assertSame(collection, collection2);
|
||||||
|
|
||||||
Collection<Integer> collection3 = CastUtil.castDown(collection2);
|
final Collection<Integer> collection3 = CastUtil.castDown(collection2);
|
||||||
Assertions.assertSame(collection2, collection3);
|
Assertions.assertSame(collection2, collection3);
|
||||||
|
|
||||||
List<Number> list2 = CastUtil.castUp(list);
|
final List<Number> list2 = CastUtil.castUp(list);
|
||||||
Assertions.assertSame(list, list2);
|
Assertions.assertSame(list, list2);
|
||||||
List<Integer> list3 = CastUtil.castDown(list2);
|
final List<Integer> list3 = CastUtil.castDown(list2);
|
||||||
Assertions.assertSame(list2, list3);
|
Assertions.assertSame(list2, list3);
|
||||||
|
|
||||||
Set<Number> set2 = CastUtil.castUp(set);
|
final Set<Number> set2 = CastUtil.castUp(set);
|
||||||
Assertions.assertSame(set, set2);
|
Assertions.assertSame(set, set2);
|
||||||
Set<Integer> set3 = CastUtil.castDown(set2);
|
final Set<Integer> set3 = CastUtil.castDown(set2);
|
||||||
Assertions.assertSame(set2, set3);
|
Assertions.assertSame(set2, set3);
|
||||||
|
|
||||||
Map<Number, Serializable> map2 = CastUtil.castUp(map);
|
final Map<Number, Serializable> map2 = CastUtil.castUp(map);
|
||||||
Assertions.assertSame(map, map2);
|
Assertions.assertSame(map, map2);
|
||||||
Map<Integer, Number> map3 = CastUtil.castDown(map2);
|
final Map<Integer, Number> map3 = CastUtil.castDown(map2);
|
||||||
Assertions.assertSame(map2, map3);
|
Assertions.assertSame(map2, map3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import java.time.LocalTime;
|
|||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.OffsetTime;
|
import java.time.OffsetTime;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class TemporalAccessorConverterTest {
|
public class TemporalAccessorConverterTest {
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ public class TemporalAccessorConverterTest {
|
|||||||
|
|
||||||
// 通过转换获取的Instant为UTC时间
|
// 通过转换获取的Instant为UTC时间
|
||||||
final Instant instant = Convert.convert(Instant.class, dateStr);
|
final Instant instant = Convert.convert(Instant.class, dateStr);
|
||||||
final Instant instant1 = DateUtil.parse(dateStr).toInstant();
|
final Instant instant1 = Objects.requireNonNull(DateUtil.parse(dateStr)).toInstant();
|
||||||
Assertions.assertEquals(instant1, instant);
|
Assertions.assertEquals(instant1, instant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ import org.dromara.hutool.core.date.chinese.GanZhi;
|
|||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class GanzhiTest {
|
public class GanzhiTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -27,7 +29,7 @@ public class GanzhiTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getCyclicalYMDTest(){
|
public void getCyclicalYMDTest(){
|
||||||
//通过公历构建
|
//通过公历构建
|
||||||
final ChineseDate chineseDate = new ChineseDate(DateUtil.parse("1993-01-06"));
|
final ChineseDate chineseDate = new ChineseDate(Objects.requireNonNull(DateUtil.parse("1993-01-06")));
|
||||||
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
||||||
Assertions.assertEquals("壬申年癸丑月丁亥日",cyclicalYMD);
|
Assertions.assertEquals("壬申年癸丑月丁亥日",cyclicalYMD);
|
||||||
}
|
}
|
||||||
@ -43,7 +45,7 @@ public class GanzhiTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getCyclicalYMDTest3(){
|
public void getCyclicalYMDTest3(){
|
||||||
//通过公历构建
|
//通过公历构建
|
||||||
final ChineseDate chineseDate = new ChineseDate(DateUtil.parse("2020-08-28"));
|
final ChineseDate chineseDate = new ChineseDate(Objects.requireNonNull(DateUtil.parse("2020-08-28")));
|
||||||
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
||||||
Assertions.assertEquals("庚子年甲申月癸卯日",cyclicalYMD);
|
Assertions.assertEquals("庚子年甲申月癸卯日",cyclicalYMD);
|
||||||
}
|
}
|
||||||
@ -51,7 +53,7 @@ public class GanzhiTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getCyclicalYMDTest4(){
|
public void getCyclicalYMDTest4(){
|
||||||
//通过公历构建
|
//通过公历构建
|
||||||
final ChineseDate chineseDate = new ChineseDate(DateUtil.parse("1905-08-28"));
|
final ChineseDate chineseDate = new ChineseDate(Objects.requireNonNull(DateUtil.parse("1905-08-28")));
|
||||||
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
||||||
Assertions.assertEquals("乙巳年甲申月己亥日",cyclicalYMD);
|
Assertions.assertEquals("乙巳年甲申月己亥日",cyclicalYMD);
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,12 @@ package org.dromara.hutool.core.date;
|
|||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class IssueI82Y1LTest {
|
public class IssueI82Y1LTest {
|
||||||
@Test
|
@Test
|
||||||
public void parseTest() {
|
public void parseTest() {
|
||||||
final String dt1 = "2023-09-14T05:00:03.648519Z";
|
final String dt1 = "2023-09-14T05:00:03.648519Z";
|
||||||
Assertions.assertEquals("2023-09-14 05:10:51", DateUtil.parse(dt1).toString());
|
Assertions.assertEquals("2023-09-14 05:10:51", Objects.requireNonNull(DateUtil.parse(dt1)).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,13 +111,13 @@ public class TimeUtilTest {
|
|||||||
Assertions.assertEquals("2020-01-23", localDate.toString());
|
Assertions.assertEquals("2020-01-23", localDate.toString());
|
||||||
|
|
||||||
localDate = TimeUtil.parseDate("2020-01-23T12:23:56", DateTimeFormatter.ISO_DATE_TIME);
|
localDate = TimeUtil.parseDate("2020-01-23T12:23:56", DateTimeFormatter.ISO_DATE_TIME);
|
||||||
Assertions.assertEquals("2020-01-23", localDate.toString());
|
Assertions.assertEquals("2020-01-23", Objects.requireNonNull(localDate).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseSingleMonthAndDayTest() {
|
public void parseSingleMonthAndDayTest() {
|
||||||
final LocalDate localDate = TimeUtil.parseDate("2020-1-1", "yyyy-M-d");
|
final LocalDate localDate = TimeUtil.parseDate("2020-1-1", "yyyy-M-d");
|
||||||
Assertions.assertEquals("2020-01-01", localDate.toString());
|
Assertions.assertEquals("2020-01-01", Objects.requireNonNull(localDate).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -47,8 +47,6 @@ public class ZodiacTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getZodiacOutOfRangeTest() {
|
public void getZodiacOutOfRangeTest() {
|
||||||
// https://github.com/dromara/hutool/issues/3036
|
// https://github.com/dromara/hutool/issues/3036
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, ()->{
|
Assertions.assertThrows(IllegalArgumentException.class, ()-> DateUtil.getZodiac(Month.UNDECIMBER.getValue(), 10));
|
||||||
DateUtil.getZodiac(Month.UNDECIMBER.getValue(), 10);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class LambdaFactoryTest {
|
|||||||
try {
|
try {
|
||||||
LambdaFactory.build(Function.class, Something.class, "setId", Long.class);
|
LambdaFactory.build(Function.class, Something.class, "setId", Long.class);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
Assertions.assertTrue(e.getCause() instanceof LambdaConversionException);
|
Assertions.assertInstanceOf(LambdaConversionException.class, e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.io.file;
|
package org.dromara.hutool.core.io.file;
|
||||||
|
|
||||||
import org.dromara.hutool.core.array.ArrayUtil;
|
import org.dromara.hutool.core.array.ArrayUtil;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -14,14 +14,11 @@ package org.dromara.hutool.core.io.watch;
|
|||||||
|
|
||||||
import org.dromara.hutool.core.io.file.PathUtil;
|
import org.dromara.hutool.core.io.file.PathUtil;
|
||||||
import org.dromara.hutool.core.io.watch.watchers.DelayWatcher;
|
import org.dromara.hutool.core.io.watch.watchers.DelayWatcher;
|
||||||
import org.dromara.hutool.core.io.watch.watchers.SimpleWatcher;
|
|
||||||
import org.dromara.hutool.core.lang.Console;
|
import org.dromara.hutool.core.lang.Console;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.WatchEvent;
|
|
||||||
import java.nio.file.WatchKey;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件监听单元测试
|
* 文件监听单元测试
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
package org.dromara.hutool.core.io.watch;
|
package org.dromara.hutool.core.io.watch;
|
||||||
|
|
||||||
import org.dromara.hutool.core.io.file.PathUtil;
|
import org.dromara.hutool.core.io.file.PathUtil;
|
||||||
import org.dromara.hutool.core.io.watch.watchers.SimpleWatcher;
|
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.nio.file.WatchEvent;
|
|
||||||
import java.nio.file.WatchKey;
|
|
||||||
|
|
||||||
public class WatchServiceWrapperTest {
|
public class WatchServiceWrapperTest {
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
|
@ -197,9 +197,9 @@ public class OptTest {
|
|||||||
return list.get(0);
|
return list.get(0);
|
||||||
}).exceptionOrElse("hutool");
|
}).exceptionOrElse("hutool");
|
||||||
|
|
||||||
Assertions.assertTrue(Opt.ofTry(() -> {
|
Assertions.assertInstanceOf(AssertionError.class, Opt.ofTry(() -> {
|
||||||
throw new AssertionError("");
|
throw new AssertionError("");
|
||||||
}).getThrowable() instanceof AssertionError);
|
}).getThrowable());
|
||||||
Assertions.assertEquals(npe, npeSituation);
|
Assertions.assertEquals(npe, npeSituation);
|
||||||
Assertions.assertEquals(indexOut, indexOutSituation);
|
Assertions.assertEquals(indexOut, indexOutSituation);
|
||||||
Assertions.assertEquals("hutool", npe);
|
Assertions.assertEquals("hutool", npe);
|
||||||
|
@ -116,9 +116,7 @@ public class ValidatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateTest() throws ValidateException {
|
public void validateTest() throws ValidateException {
|
||||||
Assertions.assertThrows(ValidateException.class, ()->{
|
Assertions.assertThrows(ValidateException.class, ()-> Validator.validateChinese("我是一段zhongwen", "内容中包含非中文"));
|
||||||
Validator.validateChinese("我是一段zhongwen", "内容中包含非中文");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -61,58 +61,58 @@ abstract class BaseMutableTest<V, M extends Mutable<V>> {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGet() {
|
void testGet() {
|
||||||
Mutable<V> mutableObj = getMutable(getValue1());
|
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||||
V value = mutableObj.get();
|
final V value = mutableObj.get();
|
||||||
Assertions.assertEquals(getValue1(), value);
|
Assertions.assertEquals(getValue1(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSet() {
|
void testSet() {
|
||||||
Mutable<V> mutableObj = getMutable(getValue2());
|
final Mutable<V> mutableObj = getMutable(getValue2());
|
||||||
mutableObj.set(getValue2());
|
mutableObj.set(getValue2());
|
||||||
V value = mutableObj.get();
|
final V value = mutableObj.get();
|
||||||
Assertions.assertEquals(getValue2(), value);
|
Assertions.assertEquals(getValue2(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTo() {
|
void testTo() {
|
||||||
Mutable<V> mutableObj = getMutable(getValue1());
|
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||||
String value = mutableObj.to(String::valueOf);
|
final String value = mutableObj.to(String::valueOf);
|
||||||
Assertions.assertEquals(String.valueOf(getValue1()), value);
|
Assertions.assertEquals(String.valueOf(getValue1()), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testToOpt() {
|
void testToOpt() {
|
||||||
Mutable<V> mutableObj = getMutable(getValue1());
|
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||||
V value = mutableObj.toOpt().get();
|
final V value = mutableObj.toOpt().get();
|
||||||
Assertions.assertEquals(getValue1(), value);
|
Assertions.assertEquals(getValue1(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testMap() {
|
void testMap() {
|
||||||
Mutable<V> mutableObj = getMutable(getValue1());
|
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||||
V value = mutableObj.map(v -> getValue2()).get();
|
final V value = mutableObj.map(v -> getValue2()).get();
|
||||||
Assertions.assertEquals(getValue2(), value);
|
Assertions.assertEquals(getValue2(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTest() {
|
void testTest() {
|
||||||
Mutable<V> mutableObj = getMutable(getValue1());
|
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||||
Assertions.assertTrue(mutableObj.test(Objects::nonNull));
|
Assertions.assertTrue(mutableObj.test(Objects::nonNull));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testPeek() {
|
void testPeek() {
|
||||||
Mutable<V> m1 = getMutable(getValue1());
|
final Mutable<V> m1 = getMutable(getValue1());
|
||||||
Mutable<V> m2 = getMutable(getValue2());
|
final Mutable<V> m2 = getMutable(getValue2());
|
||||||
m1.peek(m2::set);
|
m1.peek(m2::set);
|
||||||
Assertions.assertEquals(getValue1(), m2.get());
|
Assertions.assertEquals(getValue1(), m2.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testHashCode() {
|
void testHashCode() {
|
||||||
V value = getValue1();
|
final V value = getValue1();
|
||||||
Mutable<V> mutableObj = new MutableObj<>(value);
|
final Mutable<V> mutableObj = new MutableObj<>(value);
|
||||||
Assertions.assertEquals(value.hashCode(), mutableObj.hashCode());
|
Assertions.assertEquals(value.hashCode(), mutableObj.hashCode());
|
||||||
mutableObj.set(null);
|
mutableObj.set(null);
|
||||||
Assertions.assertEquals(0, mutableObj.hashCode());
|
Assertions.assertEquals(0, mutableObj.hashCode());
|
||||||
@ -120,10 +120,9 @@ abstract class BaseMutableTest<V, M extends Mutable<V>> {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testEquals() {
|
void testEquals() {
|
||||||
V value = getValue1();
|
final V value = getValue1();
|
||||||
Mutable<V> mutableObj = new MutableObj<>(value);
|
final Mutable<V> mutableObj = new MutableObj<>(value);
|
||||||
Assertions.assertNotEquals(value, mutableObj);
|
Assertions.assertNotEquals(value, mutableObj);
|
||||||
Assertions.assertEquals(mutableObj, mutableObj);
|
|
||||||
Assertions.assertEquals(mutableObj, new MutableObj<>(value));
|
Assertions.assertEquals(mutableObj, new MutableObj<>(value));
|
||||||
Assertions.assertNotEquals(mutableObj, new MutableObj<>(null));
|
Assertions.assertNotEquals(mutableObj, new MutableObj<>(null));
|
||||||
Assertions.assertNotEquals(mutableObj, null);
|
Assertions.assertNotEquals(mutableObj, null);
|
||||||
@ -132,8 +131,8 @@ abstract class BaseMutableTest<V, M extends Mutable<V>> {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testToString() {
|
void testToString() {
|
||||||
V value = getValue1();
|
final V value = getValue1();
|
||||||
Mutable<V> mutableObj = new MutableObj<>(value);
|
final Mutable<V> mutableObj = new MutableObj<>(value);
|
||||||
Assertions.assertEquals(value.toString(), mutableObj.toString());
|
Assertions.assertEquals(value.toString(), mutableObj.toString());
|
||||||
mutableObj.set(null);
|
mutableObj.set(null);
|
||||||
Assertions.assertEquals(StrValidator.NULL, mutableObj.toString());
|
Assertions.assertEquals(StrValidator.NULL, mutableObj.toString());
|
||||||
|
@ -25,7 +25,6 @@ public class BoundedRangeTest {
|
|||||||
final BoundedRange<Integer> range = new BoundedRange<>(
|
final BoundedRange<Integer> range = new BoundedRange<>(
|
||||||
Bound.greaterThan(0), Bound.lessThan(10)
|
Bound.greaterThan(0), Bound.lessThan(10)
|
||||||
);
|
);
|
||||||
Assertions.assertEquals(range, range);
|
|
||||||
Assertions.assertNotEquals(range, null);
|
Assertions.assertNotEquals(range, null);
|
||||||
Assertions.assertEquals(range, new BoundedRange<>(
|
Assertions.assertEquals(range, new BoundedRange<>(
|
||||||
Bound.greaterThan(0), Bound.lessThan(10)
|
Bound.greaterThan(0), Bound.lessThan(10)
|
||||||
@ -66,7 +65,6 @@ public class BoundedRangeTest {
|
|||||||
|
|
||||||
// isXXX
|
// isXXX
|
||||||
Assertions.assertFalse(range.isDisjoint(BoundedRange.open(0, 5)));
|
Assertions.assertFalse(range.isDisjoint(BoundedRange.open(0, 5)));
|
||||||
Assertions.assertEquals(range, range);
|
|
||||||
Assertions.assertNotEquals(range, BoundedRange.open(0, 5));
|
Assertions.assertNotEquals(range, BoundedRange.open(0, 5));
|
||||||
Assertions.assertTrue(range.isIntersected(BoundedRange.open(0, 5)));
|
Assertions.assertTrue(range.isIntersected(BoundedRange.open(0, 5)));
|
||||||
Assertions.assertTrue(range.isIntersected(range));
|
Assertions.assertTrue(range.isIntersected(range));
|
||||||
@ -113,7 +111,6 @@ public class BoundedRangeTest {
|
|||||||
Assertions.assertFalse(range.test(-1));
|
Assertions.assertFalse(range.test(-1));
|
||||||
|
|
||||||
// isXXX
|
// isXXX
|
||||||
Assertions.assertEquals(range, range);
|
|
||||||
Assertions.assertTrue(range.isDisjoint(BoundedRange.open(-5, 0))); // (-5, 0)
|
Assertions.assertTrue(range.isDisjoint(BoundedRange.open(-5, 0))); // (-5, 0)
|
||||||
Assertions.assertTrue(range.isDisjoint(BoundedRange.close(-5, 0))); // [-5, 0]
|
Assertions.assertTrue(range.isDisjoint(BoundedRange.close(-5, 0))); // [-5, 0]
|
||||||
Assertions.assertTrue(range.isIntersected(BoundedRange.close(-5, 1))); // [-5, 1]
|
Assertions.assertTrue(range.isIntersected(BoundedRange.close(-5, 1))); // [-5, 1]
|
||||||
@ -154,7 +151,6 @@ public class BoundedRangeTest {
|
|||||||
Assertions.assertFalse(range.test(-1));
|
Assertions.assertFalse(range.test(-1));
|
||||||
|
|
||||||
// isXXX
|
// isXXX
|
||||||
Assertions.assertEquals(range, range);
|
|
||||||
Assertions.assertTrue(range.isDisjoint(BoundedRange.open(-5, 0))); // (-5, 0)
|
Assertions.assertTrue(range.isDisjoint(BoundedRange.open(-5, 0))); // (-5, 0)
|
||||||
Assertions.assertTrue(range.isDisjoint(BoundedRange.close(-5, 0))); // [-5, 0]
|
Assertions.assertTrue(range.isDisjoint(BoundedRange.close(-5, 0))); // [-5, 0]
|
||||||
Assertions.assertTrue(range.isIntersected(BoundedRange.open(-5, 1))); // [-5, 1]
|
Assertions.assertTrue(range.isIntersected(BoundedRange.open(-5, 1))); // [-5, 1]
|
||||||
|
@ -489,7 +489,7 @@ public class NumberUtilTest {
|
|||||||
final String numberStr = "429900013E20220812163344551";
|
final String numberStr = "429900013E20220812163344551";
|
||||||
final Number number = NumberUtil.parseNumber(numberStr);
|
final Number number = NumberUtil.parseNumber(numberStr);
|
||||||
Assertions.assertNotNull(number);
|
Assertions.assertNotNull(number);
|
||||||
Assertions.assertTrue(number instanceof BigDecimal);
|
Assertions.assertInstanceOf(BigDecimal.class, number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -63,14 +63,14 @@ class UrlDecoderTest {
|
|||||||
@Test
|
@Test
|
||||||
void decodeCharSetIsNullToStrTest() {
|
void decodeCharSetIsNullToStrTest() {
|
||||||
final String hello = "你好";
|
final String hello = "你好";
|
||||||
String decode = UrlDecoder.decode(hello, null, true);
|
final String decode = UrlDecoder.decode(hello, null, true);
|
||||||
Assertions.assertEquals(hello, decode);
|
Assertions.assertEquals(hello, decode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void decodeStrIsEmptyToStrTest() {
|
void decodeStrIsEmptyToStrTest() {
|
||||||
final String strEmpty = "";
|
final String strEmpty = "";
|
||||||
String decode = UrlDecoder.decode(strEmpty, StandardCharsets.UTF_8, true);
|
final String decode = UrlDecoder.decode(strEmpty, StandardCharsets.UTF_8, true);
|
||||||
Assertions.assertEquals(strEmpty, decode);
|
Assertions.assertEquals(strEmpty, decode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,19 +78,19 @@ class UrlDecoderTest {
|
|||||||
void decodeStrWithUTF8ToStrTest() {
|
void decodeStrWithUTF8ToStrTest() {
|
||||||
final String exceptedDecode = "你好";
|
final String exceptedDecode = "你好";
|
||||||
final String encode = "%E4%BD%A0%E5%A5%BD";
|
final String encode = "%E4%BD%A0%E5%A5%BD";
|
||||||
String s1 = UrlDecoder.decode(encode);
|
final String s1 = UrlDecoder.decode(encode);
|
||||||
Assertions.assertEquals(exceptedDecode, s1);
|
Assertions.assertEquals(exceptedDecode, s1);
|
||||||
|
|
||||||
String s2 = UrlDecoder.decode(encode, StandardCharsets.UTF_8);
|
final String s2 = UrlDecoder.decode(encode, StandardCharsets.UTF_8);
|
||||||
Assertions.assertEquals(exceptedDecode, s2);
|
Assertions.assertEquals(exceptedDecode, s2);
|
||||||
|
|
||||||
String s3 = UrlDecoder.decode(encode, true);
|
final String s3 = UrlDecoder.decode(encode, true);
|
||||||
Assertions.assertEquals(exceptedDecode, s3);
|
Assertions.assertEquals(exceptedDecode, s3);
|
||||||
|
|
||||||
String s4 = UrlDecoder.decode(encode + "+", false);
|
final String s4 = UrlDecoder.decode(encode + "+", false);
|
||||||
Assertions.assertEquals(exceptedDecode + "+", s4);
|
Assertions.assertEquals(exceptedDecode + "+", s4);
|
||||||
|
|
||||||
String s5 = UrlDecoder.decode(encode, StandardCharsets.UTF_8, false);
|
final String s5 = UrlDecoder.decode(encode, StandardCharsets.UTF_8, false);
|
||||||
Assertions.assertEquals(exceptedDecode, s5);
|
Assertions.assertEquals(exceptedDecode, s5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +98,10 @@ class UrlDecoderTest {
|
|||||||
void decodeStrWithUTF8ToByteTest(){
|
void decodeStrWithUTF8ToByteTest(){
|
||||||
final String exceptedDecode = "你好";
|
final String exceptedDecode = "你好";
|
||||||
final String encode = "%E4%BD%A0%E5%A5%BD";
|
final String encode = "%E4%BD%A0%E5%A5%BD";
|
||||||
byte[] decode = UrlDecoder.decode(encode.getBytes(StandardCharsets.UTF_8));
|
final byte[] decode = UrlDecoder.decode(encode.getBytes(StandardCharsets.UTF_8));
|
||||||
Assertions.assertEquals(exceptedDecode, new String(decode,StandardCharsets.UTF_8));
|
Assertions.assertEquals(exceptedDecode, new String(decode,StandardCharsets.UTF_8));
|
||||||
|
|
||||||
byte[] decode1 = UrlDecoder.decode((encode + "+").getBytes(StandardCharsets.UTF_8));
|
final byte[] decode1 = UrlDecoder.decode((encode + "+").getBytes(StandardCharsets.UTF_8));
|
||||||
Assertions.assertEquals(exceptedDecode+" ",new String(decode1,StandardCharsets.UTF_8));
|
Assertions.assertEquals(exceptedDecode+" ",new String(decode1,StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class ClassUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
void testTraverseTypeHierarchy() {
|
void testTraverseTypeHierarchy() {
|
||||||
// collect all superclass of child by bfs (include child)
|
// collect all superclass of child by bfs (include child)
|
||||||
List<Class<?>> superclasses = new ArrayList<>();
|
final List<Class<?>> superclasses = new ArrayList<>();
|
||||||
ClassUtil.traverseTypeHierarchy(
|
ClassUtil.traverseTypeHierarchy(
|
||||||
Child.class, t -> !t.isInterface(), superclasses::add, true
|
Child.class, t -> !t.isInterface(), superclasses::add, true
|
||||||
);
|
);
|
||||||
@ -80,7 +80,7 @@ class ClassUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
void testTraverseTypeHierarchyWithTerminator() {
|
void testTraverseTypeHierarchyWithTerminator() {
|
||||||
// collect all superclass of child until Parent by bfs (include child)
|
// collect all superclass of child until Parent by bfs (include child)
|
||||||
List<Class<?>> superclasses = new ArrayList<>();
|
final List<Class<?>> superclasses = new ArrayList<>();
|
||||||
ClassUtil.traverseTypeHierarchyWhile(
|
ClassUtil.traverseTypeHierarchyWhile(
|
||||||
Child.class, t -> !t.isInterface(), t -> {
|
Child.class, t -> !t.isInterface(), t -> {
|
||||||
if (!Objects.equals(t, GrandParent.class)) {
|
if (!Objects.equals(t, GrandParent.class)) {
|
||||||
|
@ -25,41 +25,41 @@ import java.lang.reflect.Method;
|
|||||||
*/
|
*/
|
||||||
class MethodMatcherTest {
|
class MethodMatcherTest {
|
||||||
|
|
||||||
private MethodMatcher matchToString = (MethodMatcher)t -> "toString".equals(t.getName());
|
private final MethodMatcher matchToString = t -> "toString".equals(t.getName());
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Test
|
@Test
|
||||||
void test() {
|
void test() {
|
||||||
Method toString = Object.class.getDeclaredMethod("toString");
|
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||||
Assertions.assertTrue(matchToString.test(toString));
|
Assertions.assertTrue(matchToString.test(toString));
|
||||||
Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
final Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||||
Assertions.assertFalse(matchToString.test(hashCode));
|
Assertions.assertFalse(matchToString.test(hashCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Test
|
@Test
|
||||||
void and() {
|
void and() {
|
||||||
Method toString = Object.class.getDeclaredMethod("toString");
|
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||||
Assertions.assertTrue(matchToString.test(toString));
|
Assertions.assertTrue(matchToString.test(toString));
|
||||||
MethodMatcher newMatcher = matchToString.and(t -> t.getReturnType() == String.class);
|
final MethodMatcher newMatcher = matchToString.and(t -> t.getReturnType() == String.class);
|
||||||
Assertions.assertTrue(newMatcher.test(toString));
|
Assertions.assertTrue(newMatcher.test(toString));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Test
|
@Test
|
||||||
void negate() {
|
void negate() {
|
||||||
Method toString = Object.class.getDeclaredMethod("toString");
|
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||||
Assertions.assertTrue(matchToString.test(toString));
|
Assertions.assertTrue(matchToString.test(toString));
|
||||||
MethodMatcher newMatcher = matchToString.negate();
|
final MethodMatcher newMatcher = matchToString.negate();
|
||||||
Assertions.assertFalse(newMatcher.test(toString));
|
Assertions.assertFalse(newMatcher.test(toString));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Test
|
@Test
|
||||||
void or() {
|
void or() {
|
||||||
MethodMatcher newMatcher = matchToString.or(t -> "hashCode".equals(t.getName()));
|
final MethodMatcher newMatcher = matchToString.or(t -> "hashCode".equals(t.getName()));
|
||||||
Method toString = Object.class.getDeclaredMethod("toString");
|
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||||
Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
final Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||||
Assertions.assertTrue(newMatcher.test(toString));
|
Assertions.assertTrue(newMatcher.test(toString));
|
||||||
Assertions.assertTrue(newMatcher.test(hashCode));
|
Assertions.assertTrue(newMatcher.test(hashCode));
|
||||||
}
|
}
|
||||||
@ -67,9 +67,9 @@ class MethodMatcherTest {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Test
|
@Test
|
||||||
void inspect() {
|
void inspect() {
|
||||||
Method toString = Object.class.getDeclaredMethod("toString");
|
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||||
Assertions.assertTrue(matchToString.inspect(toString));
|
Assertions.assertTrue(matchToString.inspect(toString));
|
||||||
Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
final Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||||
Assertions.assertNull(matchToString.inspect(hashCode));
|
Assertions.assertNull(matchToString.inspect(hashCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -724,7 +724,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test() {
|
void test() {
|
||||||
List<List<List<String>>> list = Arrays.asList(
|
final List<List<List<String>>> list = Arrays.asList(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
Arrays.asList("a"),
|
Arrays.asList("a"),
|
||||||
Arrays.asList("b", "c"),
|
Arrays.asList("b", "c"),
|
||||||
@ -735,7 +735,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
|||||||
Arrays.asList("j", "k", "l")
|
Arrays.asList("j", "k", "l")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
List<String> r = EasyStream.of(list).<String>flat().toList();
|
final List<String> r = EasyStream.of(list).<String>flat().toList();
|
||||||
Assertions.assertArrayEquals(new String[]{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"}, r.toArray());
|
Assertions.assertArrayEquals(new String[]{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"}, r.toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class StreamUtilTest {
|
|||||||
// === iterator ===
|
// === iterator ===
|
||||||
@Test
|
@Test
|
||||||
public void streamTestNullIterator() {
|
public void streamTestNullIterator() {
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> StreamUtil.ofIter((Iterator<Object>) null));
|
Assertions.assertThrows(IllegalArgumentException.class, () -> StreamUtil.ofIter(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"RedundantOperationOnEmptyContainer", "RedundantCollectionOperation"})
|
@SuppressWarnings({"RedundantOperationOnEmptyContainer", "RedundantCollectionOperation"})
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.text;
|
package org.dromara.hutool.core.text;
|
||||||
|
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -18,10 +18,6 @@ import org.junit.jupiter.api.Assertions;
|
|||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文本相似度计算工具类单元测试
|
* 文本相似度计算工具类单元测试
|
||||||
*
|
*
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.text.split;
|
package org.dromara.hutool.core.text.split;
|
||||||
|
|
||||||
import org.dromara.hutool.core.collection.ListUtil;
|
import org.dromara.hutool.core.collection.ListUtil;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.text.finder.PatternFinder;
|
import org.dromara.hutool.core.text.finder.PatternFinder;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.thread;
|
package org.dromara.hutool.core.thread;
|
||||||
|
|
||||||
import org.dromara.hutool.core.collection.ListUtil;
|
import org.dromara.hutool.core.collection.ListUtil;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -68,7 +67,7 @@ public class AsyncUtilTest {
|
|||||||
return "真暖和";
|
return "真暖和";
|
||||||
});
|
});
|
||||||
// 等待完成
|
// 等待完成
|
||||||
List<String> list = AsyncUtil.allOfGet(ListUtil.of(hutool, sweater, warm));
|
final List<String> list = AsyncUtil.allOfGet(ListUtil.of(hutool, sweater, warm));
|
||||||
// 获取结果
|
// 获取结果
|
||||||
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
||||||
}
|
}
|
||||||
@ -81,7 +80,7 @@ public class AsyncUtilTest {
|
|||||||
return "hutool";
|
return "hutool";
|
||||||
});
|
});
|
||||||
final CompletableFuture<String> sweater = CompletableFuture.supplyAsync(() -> {
|
final CompletableFuture<String> sweater = CompletableFuture.supplyAsync(() -> {
|
||||||
int a = 1 / 0;
|
final int a = 1 / 0;
|
||||||
ThreadUtil.sleep(2, TimeUnit.SECONDS);
|
ThreadUtil.sleep(2, TimeUnit.SECONDS);
|
||||||
return "卫衣";
|
return "卫衣";
|
||||||
});
|
});
|
||||||
@ -90,7 +89,7 @@ public class AsyncUtilTest {
|
|||||||
return "真暖和";
|
return "真暖和";
|
||||||
});
|
});
|
||||||
// 等待完成
|
// 等待完成
|
||||||
List<String> list = AsyncUtil.allOfGet(ListUtil.of(hutool, sweater, warm), (e) -> "出错了");
|
final List<String> list = AsyncUtil.allOfGet(ListUtil.of(hutool, sweater, warm), (e) -> "出错了");
|
||||||
// 获取结果
|
// 获取结果
|
||||||
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
||||||
}
|
}
|
||||||
@ -111,7 +110,7 @@ public class AsyncUtilTest {
|
|||||||
return "真暖和";
|
return "真暖和";
|
||||||
});
|
});
|
||||||
// 等待完成
|
// 等待完成
|
||||||
List<String> list = AsyncUtil.parallelAllOfGet(ListUtil.of(hutool, sweater, warm));
|
final List<String> list = AsyncUtil.parallelAllOfGet(ListUtil.of(hutool, sweater, warm));
|
||||||
// 获取结果
|
// 获取结果
|
||||||
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
||||||
}
|
}
|
||||||
@ -124,7 +123,7 @@ public class AsyncUtilTest {
|
|||||||
return "hutool";
|
return "hutool";
|
||||||
});
|
});
|
||||||
final CompletableFuture<String> sweater = CompletableFuture.supplyAsync(() -> {
|
final CompletableFuture<String> sweater = CompletableFuture.supplyAsync(() -> {
|
||||||
int a = 1 / 0;
|
final int a = 1 / 0;
|
||||||
ThreadUtil.sleep(2, TimeUnit.SECONDS);
|
ThreadUtil.sleep(2, TimeUnit.SECONDS);
|
||||||
return "卫衣";
|
return "卫衣";
|
||||||
});
|
});
|
||||||
@ -133,7 +132,7 @@ public class AsyncUtilTest {
|
|||||||
return "真暖和";
|
return "真暖和";
|
||||||
});
|
});
|
||||||
// 等待完成
|
// 等待完成
|
||||||
List<String> list = AsyncUtil.parallelAllOfGet(ListUtil.of(hutool, sweater, warm), (e) -> "出错了");
|
final List<String> list = AsyncUtil.parallelAllOfGet(ListUtil.of(hutool, sweater, warm), (e) -> "出错了");
|
||||||
Assertions.assertEquals(Arrays.asList("hutool", "出错了", "真暖和"), list);
|
Assertions.assertEquals(Arrays.asList("hutool", "出错了", "真暖和"), list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public class SyncFinisherTest {
|
|||||||
/**
|
/**
|
||||||
* https://gitee.com/dromara/hutool/issues/I716SX
|
* https://gitee.com/dromara/hutool/issues/I716SX
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("DataFlowIssue")
|
||||||
@Test
|
@Test
|
||||||
void executeExceptionTest() {
|
void executeExceptionTest() {
|
||||||
final AtomicBoolean hasException = new AtomicBoolean(false);
|
final AtomicBoolean hasException = new AtomicBoolean(false);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
package org.dromara.hutool.core.thread;
|
package org.dromara.hutool.core.thread;
|
||||||
|
|
||||||
import org.dromara.hutool.core.date.TimeUtil;
|
import org.dromara.hutool.core.date.TimeUtil;
|
||||||
|
import org.dromara.hutool.core.exception.HutoolException;
|
||||||
import org.dromara.hutool.core.util.RandomUtil;
|
import org.dromara.hutool.core.util.RandomUtil;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
@ -38,14 +39,14 @@ public class ThreadUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
@Disabled
|
@Disabled
|
||||||
public void phaserTest(){
|
public void phaserTest(){
|
||||||
LocalDateTime now = TimeUtil.parse("2022-08-04T22:59:59+08:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
final LocalDateTime now = TimeUtil.parse("2022-08-04T22:59:59+08:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||||
Assertions.assertNotNull(now);
|
Assertions.assertNotNull(now);
|
||||||
|
|
||||||
int repeat = 30; // 执行的轮数配置
|
final int repeat = 30; // 执行的轮数配置
|
||||||
Phaser phaser = new Phaser() { // 进行一些处理方法的覆写
|
final Phaser phaser = new Phaser() { // 进行一些处理方法的覆写
|
||||||
//返回ture: 移相器终止,false: 移相器继续执行
|
//返回ture: 移相器终止,false: 移相器继续执行
|
||||||
@Override
|
@Override
|
||||||
protected boolean onAdvance(int phase, int registeredParties) { // 回调处理
|
protected boolean onAdvance(final int phase, final int registeredParties) { // 回调处理
|
||||||
System.out.printf("【onAdvance()处理】进阶处理操作,phase = %s、registeredParties = %s%n",
|
System.out.printf("【onAdvance()处理】进阶处理操作,phase = %s、registeredParties = %s%n",
|
||||||
phase, registeredParties);
|
phase, registeredParties);
|
||||||
return phase + 1 >= repeat || registeredParties == 0; // 终止处理
|
return phase + 1 >= repeat || registeredParties == 0; // 终止处理
|
||||||
@ -57,11 +58,11 @@ public class ThreadUtilTest {
|
|||||||
while (!phaser.isTerminated()) { // 现在没有终止Phaser执行
|
while (!phaser.isTerminated()) { // 现在没有终止Phaser执行
|
||||||
try {
|
try {
|
||||||
TimeUnit.SECONDS.sleep(RandomUtil.randomInt(1, 10)); // 增加操作延迟,模拟各个线程执行时间不多。阿超、阿珍准备爱果的时间不同
|
TimeUnit.SECONDS.sleep(RandomUtil.randomInt(1, 10)); // 增加操作延迟,模拟各个线程执行时间不多。阿超、阿珍准备爱果的时间不同
|
||||||
} catch (InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
e.printStackTrace();
|
throw new HutoolException(e);
|
||||||
}
|
}
|
||||||
phaser.arriveAndAwaitAdvance(); // 等待其他的线程就位; 准备就绪,并等待其他线程就绪; 阿超、阿珍准备好了爱果,相互等待见面共度美好的一天
|
phaser.arriveAndAwaitAdvance(); // 等待其他的线程就位; 准备就绪,并等待其他线程就绪; 阿超、阿珍准备好了爱果,相互等待见面共度美好的一天
|
||||||
String date = TimeUtil.formatNormal(now.plusYears(phaser.getPhase() - 1)); // 增加一年
|
final String date = TimeUtil.formatNormal(now.plusYears(phaser.getPhase() - 1)); // 增加一年
|
||||||
System.out.printf("【%s】%s 阿超和阿珍共度了一个美好的七夕。%n", date, Thread.currentThread().getName());
|
System.out.printf("【%s】%s 阿超和阿珍共度了一个美好的七夕。%n", date, Thread.currentThread().getName());
|
||||||
ThreadUtil.sleep(3, TimeUnit.SECONDS);
|
ThreadUtil.sleep(3, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
@ -74,8 +75,8 @@ public class ThreadUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void cyclicBarrierTest(){
|
public void cyclicBarrierTest(){
|
||||||
//示例:7个同学,集齐7个龙珠,7个同学一起召唤神龙;前后集齐了2次
|
//示例:7个同学,集齐7个龙珠,7个同学一起召唤神龙;前后集齐了2次
|
||||||
AtomicInteger times = new AtomicInteger();
|
final AtomicInteger times = new AtomicInteger();
|
||||||
CyclicBarrier barrier = new CyclicBarrier(7, ()->{
|
final CyclicBarrier barrier = new CyclicBarrier(7, ()->{
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
System.out.println("【循环栅栏业务处理】7个子线程 都收集了一颗龙珠,七颗龙珠已经收集齐全,开始召唤神龙。" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
System.out.println("【循环栅栏业务处理】7个子线程 都收集了一颗龙珠,七颗龙珠已经收集齐全,开始召唤神龙。" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
@ -86,15 +87,15 @@ public class ThreadUtilTest {
|
|||||||
while (times.get() < 2) {
|
while (times.get() < 2) {
|
||||||
try {
|
try {
|
||||||
System.out.printf("【Barrier - 收集龙珠】当前的线程名称:%s%n", Thread.currentThread().getName());
|
System.out.printf("【Barrier - 收集龙珠】当前的线程名称:%s%n", Thread.currentThread().getName());
|
||||||
int time = ThreadLocalRandom.current().nextInt(1, 10); // 等待一段时间,模拟线程的执行时间
|
final int time = ThreadLocalRandom.current().nextInt(1, 10); // 等待一段时间,模拟线程的执行时间
|
||||||
TimeUnit.SECONDS.sleep(time); // 模拟业务延迟,收集龙珠的时间
|
TimeUnit.SECONDS.sleep(time); // 模拟业务延迟,收集龙珠的时间
|
||||||
barrier.await(); // 等待,凑够了7个等待的线程
|
barrier.await(); // 等待,凑够了7个等待的线程
|
||||||
System.err.printf("〖Barrier - 举起龙珠召唤神龙〗当前的线程名称:%s\t%s%n", Thread.currentThread().getName(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
System.err.printf("〖Barrier - 举起龙珠召唤神龙〗当前的线程名称:%s\t%s%n", Thread.currentThread().getName(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
if (barrier.getParties() >= 7) {
|
if (barrier.getParties() >= 7) {
|
||||||
barrier.reset(); // 重置栅栏,等待下一次的召唤。
|
barrier.reset(); // 重置栅栏,等待下一次的召唤。
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
throw new HutoolException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "线程 - " + x).start();
|
}, "线程 - " + x).start();
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.util;
|
package org.dromara.hutool.core.util;
|
||||||
|
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ package org.dromara.hutool.core.util;
|
|||||||
|
|
||||||
import org.dromara.hutool.core.lang.Console;
|
import org.dromara.hutool.core.lang.Console;
|
||||||
import org.dromara.hutool.core.lang.mutable.MutableObj;
|
import org.dromara.hutool.core.lang.mutable.MutableObj;
|
||||||
import org.dromara.hutool.core.util.ReferenceUtil;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -29,21 +28,21 @@ public class ReferenceUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void createWeakTest(){
|
public void createWeakTest(){
|
||||||
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.WEAK, 1);
|
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.WEAK, 1);
|
||||||
Assertions.assertTrue(integerReference instanceof WeakReference);
|
Assertions.assertInstanceOf(WeakReference.class, integerReference);
|
||||||
Assertions.assertEquals(new Integer(1), integerReference.get());
|
Assertions.assertEquals(Integer.valueOf(1), integerReference.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createSoftTest(){
|
public void createSoftTest(){
|
||||||
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.SOFT, 1);
|
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.SOFT, 1);
|
||||||
Assertions.assertTrue(integerReference instanceof SoftReference);
|
Assertions.assertInstanceOf(SoftReference.class, integerReference);
|
||||||
Assertions.assertEquals(new Integer(1), integerReference.get());
|
Assertions.assertEquals(Integer.valueOf(1), integerReference.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createPhantomTest(){
|
public void createPhantomTest(){
|
||||||
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.PHANTOM, 1);
|
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.PHANTOM, 1);
|
||||||
Assertions.assertTrue(integerReference instanceof PhantomReference);
|
Assertions.assertInstanceOf(PhantomReference.class, integerReference);
|
||||||
// get方法永远都返回null,PhantomReference只能用来监控对象的GC状况
|
// get方法永远都返回null,PhantomReference只能用来监控对象的GC状况
|
||||||
Assertions.assertNull(integerReference.get());
|
Assertions.assertNull(integerReference.get());
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ package org.dromara.hutool.cron;
|
|||||||
import org.dromara.hutool.core.date.DateUnit;
|
import org.dromara.hutool.core.date.DateUnit;
|
||||||
import org.dromara.hutool.core.thread.ThreadUtil;
|
import org.dromara.hutool.core.thread.ThreadUtil;
|
||||||
import org.dromara.hutool.log.Log;
|
import org.dromara.hutool.log.Log;
|
||||||
import org.dromara.hutool.log.LogFactory;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@ -12,9 +12,7 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.crypto;
|
package org.dromara.hutool.crypto;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
import org.dromara.hutool.core.exception.HutoolException;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密异常
|
* 加密异常
|
||||||
|
@ -28,12 +28,12 @@ import java.time.Instant;
|
|||||||
* <p>参考:https://github.com/jchambers/java-otp</p>
|
* <p>参考:https://github.com/jchambers/java-otp</p>
|
||||||
* OTP基于具有时间戳计数器的OTP。
|
* OTP基于具有时间戳计数器的OTP。
|
||||||
* 通过定义纪元(T0)的开始并以时间间隔(TI)为单位计数,将当前时间戳变为整数时间计数器(TC)。 例如:
|
* 通过定义纪元(T0)的开始并以时间间隔(TI)为单位计数,将当前时间戳变为整数时间计数器(TC)。 例如:
|
||||||
*
|
* <p>
|
||||||
* TC = floor,
|
* TC = floor,
|
||||||
* TOTP = HOTP(SecretKey,TC),
|
* TOTP = HOTP(SecretKey,TC),
|
||||||
* TOTP-Value = TOTP mod 10d,其中d是一次性密码的所需位数。
|
* TOTP-Value = TOTP mod 10d,其中d是一次性密码的所需位数。
|
||||||
* 像google auth的二步认证使用了这种方式。
|
* 像google auth的二步认证使用了这种方式。
|
||||||
*
|
* <p>
|
||||||
* 认证过程
|
* 认证过程
|
||||||
* 生成二维码,带有otpauth链接的google地址
|
* 生成二维码,带有otpauth链接的google地址
|
||||||
* 生成公用密钥
|
* 生成公用密钥
|
||||||
@ -42,8 +42,7 @@ import java.time.Instant;
|
|||||||
* app每30秒生成一个6位校验码,用户使用这个码来网站进行登陆
|
* app每30秒生成一个6位校验码,用户使用这个码来网站进行登陆
|
||||||
* 服务器使用存储的密钥+fmac算法生成6位随机数,与客户端传来的数进行对比
|
* 服务器使用存储的密钥+fmac算法生成6位随机数,与客户端传来的数进行对比
|
||||||
* 两个码相等,授权成功,反之,失败.(注意,服务端可以根据当前登陆的用户名拿到它的密钥,有了密钥,再进行totp的算法生成校验码)
|
* 两个码相等,授权成功,反之,失败.(注意,服务端可以根据当前登陆的用户名拿到它的密钥,有了密钥,再进行totp的算法生成校验码)
|
||||||
*
|
* <p>
|
||||||
*
|
|
||||||
* 登陆的过程整理
|
* 登陆的过程整理
|
||||||
* 用户和密码先登陆
|
* 用户和密码先登陆
|
||||||
* session里存储了用户名等信息
|
* session里存储了用户名等信息
|
||||||
@ -53,7 +52,6 @@ import java.time.Instant;
|
|||||||
* 提交到服务端,服务端根据用户名取出对应的密钥,然后使用totp算法生成6位数字
|
* 提交到服务端,服务端根据用户名取出对应的密钥,然后使用totp算法生成6位数字
|
||||||
* 如果服务端与客户端数字相同,表示登陆成功!
|
* 如果服务端与客户端数字相同,表示登陆成功!
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class TOTP extends HOTP {
|
public class TOTP extends HOTP {
|
||||||
|
@ -14,7 +14,6 @@ package org.dromara.hutool.crypto.symmetric;
|
|||||||
|
|
||||||
import org.dromara.hutool.core.codec.binary.Base64;
|
import org.dromara.hutool.core.codec.binary.Base64;
|
||||||
import org.dromara.hutool.core.codec.HexUtil;
|
import org.dromara.hutool.core.codec.HexUtil;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.util.RandomUtil;
|
import org.dromara.hutool.core.util.RandomUtil;
|
||||||
import org.dromara.hutool.crypto.KeyUtil;
|
import org.dromara.hutool.crypto.KeyUtil;
|
||||||
import org.dromara.hutool.crypto.Mode;
|
import org.dromara.hutool.crypto.Mode;
|
||||||
|
@ -24,7 +24,7 @@ public class ChaCha20Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encryptAndDecryptTest() {
|
public void encryptAndDecryptTest() {
|
||||||
// 32 for 256 bit key or 16 for 128 bit
|
// 32 for 256-bit key or 16 for 128 bit
|
||||||
final byte[] key = RandomUtil.randomBytes(32);
|
final byte[] key = RandomUtil.randomBytes(32);
|
||||||
// 64 bit IV required by ChaCha20
|
// 64 bit IV required by ChaCha20
|
||||||
final byte[] iv = RandomUtil.randomBytes(12);
|
final byte[] iv = RandomUtil.randomBytes(12);
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.crypto.symmetric;
|
package org.dromara.hutool.crypto.symmetric;
|
||||||
|
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
import org.dromara.hutool.core.text.StrUtil;
|
||||||
import org.dromara.hutool.core.util.ByteUtil;
|
import org.dromara.hutool.core.util.ByteUtil;
|
||||||
import org.dromara.hutool.crypto.KeyUtil;
|
import org.dromara.hutool.crypto.KeyUtil;
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.crypto.symmetric;
|
package org.dromara.hutool.crypto.symmetric;
|
||||||
|
|
||||||
import org.dromara.hutool.core.util.CharsetUtil;
|
import org.dromara.hutool.core.util.CharsetUtil;
|
||||||
import org.dromara.hutool.crypto.provider.GlobalProviderFactory;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import org.dromara.hutool.db.dialect.Dialect;
|
|||||||
import org.dromara.hutool.db.dialect.DialectFactory;
|
import org.dromara.hutool.db.dialect.DialectFactory;
|
||||||
import org.dromara.hutool.db.ds.DSUtil;
|
import org.dromara.hutool.db.ds.DSUtil;
|
||||||
import org.dromara.hutool.log.Log;
|
import org.dromara.hutool.log.Log;
|
||||||
import org.dromara.hutool.log.LogFactory;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
@ -72,6 +72,12 @@ public class SqlFormatter {
|
|||||||
private static final String indentString = " ";
|
private static final String indentString = " ";
|
||||||
private static final String initial = "\n ";
|
private static final String initial = "\n ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化
|
||||||
|
*
|
||||||
|
* @param source SQL语句
|
||||||
|
* @return 格式化后的SQL
|
||||||
|
*/
|
||||||
public static String format(final String source) {
|
public static String format(final String source) {
|
||||||
return new FormatProcess(source).perform().trim();
|
return new FormatProcess(source).perform().trim();
|
||||||
}
|
}
|
||||||
@ -110,24 +116,31 @@ public class SqlFormatter {
|
|||||||
this.token = this.tokens.nextToken();
|
this.token = this.tokens.nextToken();
|
||||||
this.lcToken = this.token.toLowerCase();
|
this.lcToken = this.token.toLowerCase();
|
||||||
|
|
||||||
if ("'".equals(this.token)) {
|
switch (this.token) {
|
||||||
|
case "'": {
|
||||||
String t;
|
String t;
|
||||||
do {
|
do {
|
||||||
t = this.tokens.nextToken();
|
t = this.tokens.nextToken();
|
||||||
this.token += t;
|
this.token += t;
|
||||||
} while ((!"'".equals(t)) && (this.tokens.hasMoreTokens()));
|
} while ((!"'".equals(t)) && (this.tokens.hasMoreTokens()));
|
||||||
} else if ("\"".equals(this.token)) {
|
break;
|
||||||
|
}
|
||||||
|
case "\"": {
|
||||||
String t;
|
String t;
|
||||||
do {
|
do {
|
||||||
t = this.tokens.nextToken();
|
t = this.tokens.nextToken();
|
||||||
this.token += t;
|
this.token += t;
|
||||||
} while (!"\"".equals(t));
|
} while (!"\"".equals(t));
|
||||||
} else if ("`".equals(this.token)) {
|
break;
|
||||||
|
}
|
||||||
|
case "`": {
|
||||||
String t;
|
String t;
|
||||||
do {
|
do {
|
||||||
t = this.tokens.nextToken();
|
t = this.tokens.nextToken();
|
||||||
this.token += t;
|
this.token += t;
|
||||||
} while (!"`".equals(t));
|
} while (!"`".equals(t));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this.afterByOrSetOrFromOrSelect) && (",".equals(this.token))) {
|
if ((this.afterByOrSetOrFromOrSelect) && (",".equals(this.token))) {
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.extra.aop.engine.spring;
|
package org.dromara.hutool.extra.aop.engine.spring;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
|
||||||
import org.dromara.hutool.extra.aop.Aspect;
|
import org.dromara.hutool.extra.aop.Aspect;
|
||||||
import org.dromara.hutool.extra.aop.SimpleInterceptor;
|
import org.dromara.hutool.extra.aop.SimpleInterceptor;
|
||||||
import org.springframework.cglib.proxy.MethodInterceptor;
|
import org.springframework.cglib.proxy.MethodInterceptor;
|
||||||
|
@ -238,7 +238,7 @@ public class ManagementUtil {
|
|||||||
* 获取Java虚拟机中的{@link MemoryPoolMXBean}列表<br>
|
* 获取Java虚拟机中的{@link MemoryPoolMXBean}列表<br>
|
||||||
* The Java virtual machine can have one or more memory pools. It may add or remove memory pools during execution.
|
* The Java virtual machine can have one or more memory pools. It may add or remove memory pools during execution.
|
||||||
*
|
*
|
||||||
* @return a list of <tt>MemoryPoolMXBean</tt> objects.
|
* @return a list of <b>MemoryPoolMXBean</b> objects.
|
||||||
*/
|
*/
|
||||||
public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
|
public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
|
||||||
return ManagementFactory.getMemoryPoolMXBeans();
|
return ManagementFactory.getMemoryPoolMXBeans();
|
||||||
@ -248,7 +248,7 @@ public class ManagementUtil {
|
|||||||
* 获取Java虚拟机中的{@link MemoryManagerMXBean}列表<br>
|
* 获取Java虚拟机中的{@link MemoryManagerMXBean}列表<br>
|
||||||
* The Java virtual machine can have one or more memory managers. It may add or remove memory managers during execution.
|
* The Java virtual machine can have one or more memory managers. It may add or remove memory managers during execution.
|
||||||
*
|
*
|
||||||
* @return a list of <tt>MemoryManagerMXBean</tt> objects.
|
* @return a list of <b>MemoryManagerMXBean</b> objects.
|
||||||
*/
|
*/
|
||||||
public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() {
|
public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() {
|
||||||
return ManagementFactory.getMemoryManagerMXBeans();
|
return ManagementFactory.getMemoryManagerMXBeans();
|
||||||
|
@ -26,7 +26,6 @@ import com.google.zxing.common.GlobalHistogramBinarizer;
|
|||||||
import com.google.zxing.common.HybridBinarizer;
|
import com.google.zxing.common.HybridBinarizer;
|
||||||
|
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@ import com.chenlb.mmseg4j.ComplexSeg;
|
|||||||
import com.chenlb.mmseg4j.Dictionary;
|
import com.chenlb.mmseg4j.Dictionary;
|
||||||
import com.chenlb.mmseg4j.MMSeg;
|
import com.chenlb.mmseg4j.MMSeg;
|
||||||
|
|
||||||
import java.io.StringReader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mmseg4j分词引擎实现<br>
|
* mmseg4j分词引擎实现<br>
|
||||||
* 项目地址:https://github.com/chenlb/mmseg4j-core<br>
|
* 项目地址:https://github.com/chenlb/mmseg4j-core<br>
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.extra.ssh;
|
package org.dromara.hutool.extra.ssh;
|
||||||
|
|
||||||
import org.dromara.hutool.core.util.CharsetUtil;
|
|
||||||
import org.dromara.hutool.extra.ssh.engine.sshj.SshjSftp;
|
import org.dromara.hutool.extra.ssh.engine.sshj.SshjSftp;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
@ -14,7 +14,6 @@ package org.dromara.hutool.http.client.engine.jdk;
|
|||||||
|
|
||||||
import org.dromara.hutool.core.io.IoUtil;
|
import org.dromara.hutool.core.io.IoUtil;
|
||||||
import org.dromara.hutool.core.io.stream.EmptyInputStream;
|
import org.dromara.hutool.core.io.stream.EmptyInputStream;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
|
||||||
import org.dromara.hutool.core.array.ArrayUtil;
|
import org.dromara.hutool.core.array.ArrayUtil;
|
||||||
import org.dromara.hutool.core.util.ObjUtil;
|
import org.dromara.hutool.core.util.ObjUtil;
|
||||||
import org.dromara.hutool.http.HttpException;
|
import org.dromara.hutool.http.HttpException;
|
||||||
@ -32,7 +31,6 @@ import java.nio.charset.Charset;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Http响应类<br>
|
* Http响应类<br>
|
||||||
|
@ -47,6 +47,7 @@ public class DownloadTest {
|
|||||||
Console.log("ok");
|
Console.log("ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
@Test
|
@Test
|
||||||
@Disabled
|
@Disabled
|
||||||
public void downloadSizeTest() {
|
public void downloadSizeTest() {
|
||||||
@ -123,9 +124,9 @@ public class DownloadTest {
|
|||||||
Assertions.assertTrue(file.exists());
|
Assertions.assertTrue(file.exists());
|
||||||
Assertions.assertTrue(file.isFile());
|
Assertions.assertTrue(file.isFile());
|
||||||
Assertions.assertTrue(file.length() > 0);
|
Assertions.assertTrue(file.length() > 0);
|
||||||
Assertions.assertTrue(file.getName().length() > 0);
|
Assertions.assertFalse(file.getName().isEmpty());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
Assertions.assertTrue(e instanceof IORuntimeException);
|
Assertions.assertInstanceOf(IORuntimeException.class, e);
|
||||||
} finally {
|
} finally {
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
}
|
}
|
||||||
@ -157,7 +158,7 @@ public class DownloadTest {
|
|||||||
Assertions.assertTrue(file.exists());
|
Assertions.assertTrue(file.exists());
|
||||||
Assertions.assertTrue(file.isFile());
|
Assertions.assertTrue(file.isFile());
|
||||||
Assertions.assertTrue(file.length() > 0);
|
Assertions.assertTrue(file.length() > 0);
|
||||||
Assertions.assertTrue(file.getName().length() > 0);
|
Assertions.assertFalse(file.getName().isEmpty());
|
||||||
} finally {
|
} finally {
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
}
|
}
|
||||||
@ -174,9 +175,9 @@ public class DownloadTest {
|
|||||||
Assertions.assertTrue(file.exists());
|
Assertions.assertTrue(file.exists());
|
||||||
Assertions.assertTrue(file.isFile());
|
Assertions.assertTrue(file.isFile());
|
||||||
Assertions.assertTrue(file.length() > 0);
|
Assertions.assertTrue(file.length() > 0);
|
||||||
Assertions.assertTrue(file.getName().length() > 0);
|
Assertions.assertFalse(file.getName().isEmpty());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
Assertions.assertTrue(e instanceof IORuntimeException);
|
Assertions.assertInstanceOf(IORuntimeException.class, e);
|
||||||
} finally {
|
} finally {
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class AsymmetricJWTSigner implements JWTSigner {
|
|||||||
* @param data 数据
|
* @param data 数据
|
||||||
* @return 签名
|
* @return 签名
|
||||||
*/
|
*/
|
||||||
protected byte[] sign(byte[] data) {
|
protected byte[] sign(final byte[] data) {
|
||||||
return sign.sign(data);
|
return sign.sign(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ public class AsymmetricJWTSigner implements JWTSigner {
|
|||||||
* @param signed 签名
|
* @param signed 签名
|
||||||
* @return 是否通过
|
* @return 是否通过
|
||||||
*/
|
*/
|
||||||
protected boolean verify(byte[] data, byte[] signed) {
|
protected boolean verify(final byte[] data, final byte[] signed) {
|
||||||
return sign.verify(data, signed);
|
return sign.verify(data, signed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,9 @@ public class Issue3274Test {
|
|||||||
male("male", "Male", "男"),
|
male("male", "Male", "男"),
|
||||||
female("female", "Female", "女"),
|
female("female", "Female", "女"),
|
||||||
other("other", "Other", "其他");
|
other("other", "Other", "其他");
|
||||||
private JSONArray display;
|
private final JSONArray display;
|
||||||
private String enum_name;
|
private final String enum_name;
|
||||||
|
|
||||||
Gender(final String enum_name, final String en_Us, final String zh_CN) {
|
Gender(final String enum_name, final String en_Us, final String zh_CN) {
|
||||||
this.enum_name = enum_name;
|
this.enum_name = enum_name;
|
||||||
this.display = new JSONArray("[{\"lang\": \"en-US\",\"value\": \"" + en_Us + "\"},{\"lang\": \"zh-CN\",\"value\": \"" + zh_CN + "\"}]");
|
this.display = new JSONArray("[{\"lang\": \"en-US\",\"value\": \"" + en_Us + "\"},{\"lang\": \"zh-CN\",\"value\": \"" + zh_CN + "\"}]");
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.json;
|
package org.dromara.hutool.json;
|
||||||
|
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.lang.tuple.Pair;
|
import org.dromara.hutool.core.lang.tuple.Pair;
|
||||||
import org.dromara.hutool.core.lang.tuple.Triple;
|
import org.dromara.hutool.core.lang.tuple.Triple;
|
||||||
import org.dromara.hutool.core.lang.tuple.Tuple;
|
import org.dromara.hutool.core.lang.tuple.Tuple;
|
||||||
|
@ -14,7 +14,6 @@ package org.dromara.hutool.json;
|
|||||||
|
|
||||||
import org.dromara.hutool.core.collection.ListUtil;
|
import org.dromara.hutool.core.collection.ListUtil;
|
||||||
import org.dromara.hutool.core.date.DateUtil;
|
import org.dromara.hutool.core.date.DateUtil;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.map.MapUtil;
|
import org.dromara.hutool.core.map.MapUtil;
|
||||||
import org.dromara.hutool.core.math.NumberUtil;
|
import org.dromara.hutool.core.math.NumberUtil;
|
||||||
import org.dromara.hutool.json.serialize.JSONStringer;
|
import org.dromara.hutool.json.serialize.JSONStringer;
|
||||||
|
@ -14,7 +14,6 @@ package org.dromara.hutool.log.engine.log4j;
|
|||||||
|
|
||||||
import org.dromara.hutool.log.AbsLogEngine;
|
import org.dromara.hutool.log.AbsLogEngine;
|
||||||
import org.dromara.hutool.log.Log;
|
import org.dromara.hutool.log.Log;
|
||||||
import org.dromara.hutool.log.LogFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <a href="http://logging.apache.org/log4j/1.2/index.html">Apache Log4J</a> log.<br>
|
* <a href="http://logging.apache.org/log4j/1.2/index.html">Apache Log4J</a> log.<br>
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.poi.excel;
|
package org.dromara.hutool.poi.excel;
|
||||||
|
|
||||||
import org.dromara.hutool.core.collection.ListUtil;
|
import org.dromara.hutool.core.collection.ListUtil;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
import org.dromara.hutool.core.text.StrUtil;
|
||||||
import org.dromara.hutool.poi.excel.cell.CellEditor;
|
import org.dromara.hutool.poi.excel.cell.CellEditor;
|
||||||
import org.dromara.hutool.poi.excel.cell.CellUtil;
|
import org.dromara.hutool.poi.excel.cell.CellUtil;
|
||||||
@ -25,7 +24,6 @@ import org.apache.poi.ss.util.CellRangeUtil;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
@ -214,6 +214,8 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
|||||||
// 先关闭之前的监听
|
// 先关闭之前的监听
|
||||||
IoUtil.closeQuietly(this.watchMonitor);
|
IoUtil.closeQuietly(this.watchMonitor);
|
||||||
this.watchMonitor = WatchUtil.ofModify(resource.getUrl(), new SimpleWatcher() {
|
this.watchMonitor = WatchUtil.ofModify(resource.getUrl(), new SimpleWatcher() {
|
||||||
|
private static final long serialVersionUID = 5190107321461226190L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onModify(final WatchEvent<?> event, final WatchKey key) {
|
public void onModify(final WatchEvent<?> event, final WatchKey key) {
|
||||||
final boolean success = load();
|
final boolean success = load();
|
||||||
|
@ -231,6 +231,8 @@ public final class Props extends Properties implements TypeGetter<CharSequence>
|
|||||||
// 先关闭之前的监听
|
// 先关闭之前的监听
|
||||||
IoUtil.closeQuietly(this.watchMonitor);
|
IoUtil.closeQuietly(this.watchMonitor);
|
||||||
this.watchMonitor = WatchUtil.ofModify(this.resource.getUrl(), new SimpleWatcher() {
|
this.watchMonitor = WatchUtil.ofModify(this.resource.getUrl(), new SimpleWatcher() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onModify(final WatchEvent<?> event, final WatchKey key) {
|
public void onModify(final WatchEvent<?> event, final WatchKey key) {
|
||||||
load();
|
load();
|
||||||
|
@ -15,6 +15,7 @@ package org.dromara.hutool.setting.toml;
|
|||||||
import org.dromara.hutool.core.array.ArrayUtil;
|
import org.dromara.hutool.core.array.ArrayUtil;
|
||||||
import org.dromara.hutool.core.io.IORuntimeException;
|
import org.dromara.hutool.core.io.IORuntimeException;
|
||||||
import org.dromara.hutool.core.text.CharUtil;
|
import org.dromara.hutool.core.text.CharUtil;
|
||||||
|
import org.dromara.hutool.core.text.StrUtil;
|
||||||
import org.dromara.hutool.setting.SettingException;
|
import org.dromara.hutool.setting.SettingException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -199,7 +200,7 @@ public class TomlWriter {
|
|||||||
indent();
|
indent();
|
||||||
writeKey(name);
|
writeKey(name);
|
||||||
write(" = ");
|
write(" = ");
|
||||||
writeString(ArrayUtil.toString(array));
|
writeString(StrUtil.emptyIfNull(ArrayUtil.toString(array)));
|
||||||
}
|
}
|
||||||
} else if (value instanceof Map) {// table
|
} else if (value instanceof Map) {// table
|
||||||
if (simpleValues) {
|
if (simpleValues) {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.setting.toml;
|
package org.dromara.hutool.setting.toml;
|
||||||
|
|
||||||
import org.dromara.hutool.core.io.resource.ResourceUtil;
|
import org.dromara.hutool.core.io.resource.ResourceUtil;
|
||||||
import org.dromara.hutool.core.lang.Console;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import org.dromara.hutool.socket.aio.AioSession;
|
|||||||
public interface MsgDecoder<T> {
|
public interface MsgDecoder<T> {
|
||||||
/**
|
/**
|
||||||
* 对于从Socket流中获取到的数据采用当前MsgDecoder的实现类协议进行解析。
|
* 对于从Socket流中获取到的数据采用当前MsgDecoder的实现类协议进行解析。
|
||||||
* <p>
|
|
||||||
*
|
*
|
||||||
* @param session 本次需要解码的session
|
* @param session 本次需要解码的session
|
||||||
* @param readBuffer 待处理的读buffer
|
* @param readBuffer 待处理的读buffer
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.swing.img;
|
package org.dromara.hutool.swing.img;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
import org.dromara.hutool.core.io.IORuntimeException;
|
import org.dromara.hutool.core.io.IORuntimeException;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
@ -31,7 +31,7 @@ public abstract class AnsiLabMapping {
|
|||||||
* @param color {@link LabColor}
|
* @param color {@link LabColor}
|
||||||
* @return 最接近的Ansi4BitColor
|
* @return 最接近的Ansi4BitColor
|
||||||
*/
|
*/
|
||||||
public AnsiElement lookupClosest(Color color) {
|
public AnsiElement lookupClosest(final Color color) {
|
||||||
return lookupClosest(new LabColor(color));
|
return lookupClosest(new LabColor(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,11 +41,11 @@ public abstract class AnsiLabMapping {
|
|||||||
* @param color {@link LabColor}
|
* @param color {@link LabColor}
|
||||||
* @return 最接近的Ansi4BitColor
|
* @return 最接近的Ansi4BitColor
|
||||||
*/
|
*/
|
||||||
public AnsiElement lookupClosest(LabColor color) {
|
public AnsiElement lookupClosest(final LabColor color) {
|
||||||
AnsiElement closest = null;
|
AnsiElement closest = null;
|
||||||
double closestDistance = Float.MAX_VALUE;
|
double closestDistance = Float.MAX_VALUE;
|
||||||
for (Map.Entry<AnsiElement, LabColor> entry : ansiLabMap.entrySet()) {
|
for (final Map.Entry<AnsiElement, LabColor> entry : ansiLabMap.entrySet()) {
|
||||||
double candidateDistance = color.getDistance(entry.getValue());
|
final double candidateDistance = color.getDistance(entry.getValue());
|
||||||
if (closest == null || candidateDistance < closestDistance) {
|
if (closest == null || candidateDistance < closestDistance) {
|
||||||
closestDistance = candidateDistance;
|
closestDistance = candidateDistance;
|
||||||
closest = entry.getKey();
|
closest = entry.getKey();
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user