mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.core.codec;
|
||||
|
||||
import cn.hutool.core.codec.BaseN.Base16Codec;
|
||||
import cn.hutool.core.codec.binary.Base16Codec;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.core.codec;
|
||||
|
||||
import cn.hutool.core.codec.BaseN.Base16Codec;
|
||||
import cn.hutool.core.codec.binary.Base16Codec;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.text.CharPool;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.codec.Decoder;
|
||||
import cn.hutool.core.codec.Encoder;
|
||||
@@ -81,7 +81,7 @@ public class Base16Codec implements Encoder<byte[], char[]>, Decoder<CharSequenc
|
||||
* 转换的字符串如果u后不足4位,则前面用0填充,例如:
|
||||
*
|
||||
* <pre>
|
||||
* '你' =》'\u4f60'
|
||||
* '你' =》'\u4f60'
|
||||
* </pre>
|
||||
*
|
||||
* @param ch char值
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.codec.Decoder;
|
||||
import cn.hutool.core.codec.Encoder;
|
||||
@@ -21,6 +21,9 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class Base32Codec implements Encoder<byte[], String>, Decoder<CharSequence, byte[]> {
|
||||
|
||||
/**
|
||||
* 单例对象
|
||||
*/
|
||||
public static Base32Codec INSTANCE = new Base32Codec();
|
||||
|
||||
@Override
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.codec.Decoder;
|
||||
import cn.hutool.core.codec.Encoder;
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.codec.Decoder;
|
||||
import cn.hutool.core.codec.Encoder;
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
@@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.codec.BaseN;
|
||||
package cn.hutool.core.codec.binary;
|
||||
|
||||
import cn.hutool.core.codec.Decoder;
|
||||
import cn.hutool.core.lang.mutable.MutableInt;
|
||||
@@ -13,6 +13,9 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
*/
|
||||
public class Base64Decoder implements Decoder<byte[], byte[]> {
|
||||
|
||||
/**
|
||||
* 单例对象
|
||||
*/
|
||||
public static Base64Decoder INSTANCE = new Base64Decoder();
|
||||
|
||||
private static final byte PADDING = -2;
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* BaseN编码解码,提供将bytes和baseN的编码转换功能。
|
||||
* <ul>
|
||||
* <li>Base16</li>
|
||||
* <li>Base32</li>
|
||||
* <li>Base58</li>
|
||||
* <li>Base62</li>
|
||||
* <li>Base64</li>
|
||||
* </ul>
|
||||
*/
|
||||
package cn.hutool.core.codec.binary;
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.core.convert.impl;
|
||||
|
||||
import cn.hutool.core.codec.BaseN.Base64;
|
||||
import cn.hutool.core.codec.binary.Base64;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.convert.AbstractConverter;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
@@ -164,8 +164,6 @@ public class TemporalAccessorUtil extends TemporalUtil{
|
||||
result = ((OffsetTime) temporalAccessor).atDate(LocalDate.now()).toInstant();
|
||||
} else {
|
||||
// issue#1891@Github
|
||||
// Instant.from不能完成日期转换
|
||||
//result = Instant.from(temporalAccessor);
|
||||
result = toInstant(TimeUtil.of(temporalAccessor));
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,10 @@ import cn.hutool.core.date.format.DefaultDateBasic;
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class CSTDateParser extends DefaultDateBasic implements DateParser {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 单例对象
|
||||
*/
|
||||
public static CSTDateParser INSTANCE = new CSTDateParser();
|
||||
|
||||
@Override
|
||||
|
@@ -21,7 +21,11 @@ import cn.hutool.core.util.CharUtil;
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class NormalDateParser extends DefaultDateBasic implements DateParser {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 单例
|
||||
*/
|
||||
public static NormalDateParser INSTANCE = new NormalDateParser();
|
||||
|
||||
@Override
|
||||
|
@@ -16,6 +16,7 @@ import java.util.Locale;
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class PatternsDateParser extends DefaultDateBasic implements DateParser {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 创建 PatternsDateParser
|
||||
|
@@ -18,7 +18,11 @@ import cn.hutool.core.date.format.DefaultDateBasic;
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class PureDateParser extends DefaultDateBasic implements DateParser {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 单例
|
||||
*/
|
||||
public static PureDateParser INSTANCE = new PureDateParser();
|
||||
|
||||
@Override
|
||||
|
@@ -17,7 +17,11 @@ import cn.hutool.core.text.StrUtil;
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class TimeParser extends DefaultDateBasic implements DateParser {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 单例
|
||||
*/
|
||||
public static TimeParser INSTANCE = new TimeParser();
|
||||
|
||||
@Override
|
||||
|
@@ -109,6 +109,7 @@ public class UTCDateParser extends DefaultDateBasic implements DateParser {
|
||||
* @param after 毫秒部分的后一个字符
|
||||
* @return 规范之后的毫秒部分
|
||||
*/
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static String normalizeMillSeconds(final String dateStr, final CharSequence before, final CharSequence after) {
|
||||
if (StrUtil.isBlank(after)) {
|
||||
final String millOrNaco = StrUtil.subPre(StrUtil.subAfter(dateStr, before, true), 3);
|
||||
|
@@ -6,28 +6,66 @@ package cn.hutool.core.exceptions;
|
||||
* @author looly
|
||||
*/
|
||||
public class InvocationTargetRuntimeException extends UtilException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param e 异常
|
||||
*/
|
||||
public InvocationTargetRuntimeException(final Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
public InvocationTargetRuntimeException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param messageTemplate 消息模板
|
||||
* @param params 参数
|
||||
*/
|
||||
public InvocationTargetRuntimeException(final String messageTemplate, final Object... params) {
|
||||
super(messageTemplate, params);
|
||||
}
|
||||
|
||||
public InvocationTargetRuntimeException(final String message, final Throwable throwable) {
|
||||
super(message, throwable);
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param message 消息
|
||||
* @param cause 被包装的子异常
|
||||
*/
|
||||
public InvocationTargetRuntimeException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public InvocationTargetRuntimeException(final String message, final Throwable throwable, final boolean enableSuppression, final boolean writableStackTrace) {
|
||||
super(message, throwable, enableSuppression, writableStackTrace);
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param message 消息
|
||||
* @param cause 被包装的子异常
|
||||
* @param enableSuppression 是否启用抑制
|
||||
* @param writableStackTrace 堆栈跟踪是否应该是可写的
|
||||
*/
|
||||
public InvocationTargetRuntimeException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public InvocationTargetRuntimeException(final Throwable throwable, final String messageTemplate, final Object... params) {
|
||||
super(throwable, messageTemplate, params);
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param cause 被包装的子异常
|
||||
* @param messageTemplate 消息模板
|
||||
* @param params 参数
|
||||
*/
|
||||
public InvocationTargetRuntimeException(final Throwable cause, final String messageTemplate, final Object... params) {
|
||||
super(cause, messageTemplate, params);
|
||||
}
|
||||
}
|
||||
|
@@ -10,8 +10,8 @@ import cn.hutool.core.text.StrUtil;
|
||||
public class UtilException extends RuntimeException {
|
||||
private static final long serialVersionUID = 8247610319171014183L;
|
||||
|
||||
public UtilException(final Throwable e) {
|
||||
super(ExceptionUtil.getMessage(e), e);
|
||||
public UtilException(final Throwable cause) {
|
||||
super(ExceptionUtil.getMessage(cause), cause);
|
||||
}
|
||||
|
||||
public UtilException(final String message) {
|
||||
@@ -22,15 +22,15 @@ public class UtilException extends RuntimeException {
|
||||
super(StrUtil.format(messageTemplate, params));
|
||||
}
|
||||
|
||||
public UtilException(final String message, final Throwable throwable) {
|
||||
super(message, throwable);
|
||||
public UtilException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public UtilException(final String message, final Throwable throwable, final boolean enableSuppression, final boolean writableStackTrace) {
|
||||
super(message, throwable, enableSuppression, writableStackTrace);
|
||||
public UtilException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public UtilException(final Throwable throwable, final String messageTemplate, final Object... params) {
|
||||
super(StrUtil.format(messageTemplate, params), throwable);
|
||||
public UtilException(final Throwable cause, final String messageTemplate, final Object... params) {
|
||||
super(StrUtil.format(messageTemplate, params), cause);
|
||||
}
|
||||
}
|
||||
|
@@ -882,6 +882,19 @@ public class IoUtil extends NioUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭<br>
|
||||
* 关闭失败不会抛出异常
|
||||
*
|
||||
* @param closeable 被关闭的对象
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
public static void nullSafeClose(final Closeable closeable) throws IOException {
|
||||
if (null != closeable) {
|
||||
closeable.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试关闭指定对象<br>
|
||||
* 判断对象如果实现了{@link AutoCloseable},则调用之
|
||||
|
@@ -59,7 +59,6 @@ public class PathCopier extends SrcToDestCopier<Path, PathCopier> {
|
||||
this.src = src;
|
||||
this.target = Assert.notNull(target, "Target path must be not null !");
|
||||
this.options = ObjUtil.defaultIfNull(options, new CopyOption[]{});
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -58,7 +58,7 @@ public class PathMover {
|
||||
}
|
||||
this.src = src;
|
||||
this.target = Assert.notNull(target, "Target path must be not null !");
|
||||
this.options = ObjUtil.defaultIfNull(options, new CopyOption[]{});;
|
||||
this.options = ObjUtil.defaultIfNull(options, new CopyOption[]{});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package cn.hutool.core.io.stream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
@@ -47,11 +46,10 @@ public class EmptyOutputStream extends OutputStream {
|
||||
* 什么也不做,写出到 {@code /dev/null}.
|
||||
*
|
||||
* @param b 写出的数据
|
||||
* @throws IOException 不抛出
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public void write(final byte[] b) throws IOException {
|
||||
public void write(final byte[] b) {
|
||||
// to /dev/null
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@ import java.util.stream.Collectors;
|
||||
* @since 5.8.0
|
||||
*/
|
||||
public class ReferenceConcurrentMap<K, V> implements ConcurrentMap<K, V>, Iterable<Map.Entry<K, V>>, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
final ConcurrentMap<Reference<K>, V> raw;
|
||||
private final ReferenceQueue<K> lastQueue;
|
||||
|
@@ -39,7 +39,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
|
||||
*
|
||||
* @param mapFactory 生成集合的工厂方法
|
||||
*/
|
||||
protected AbsCollValueMap(Supplier<Map<K, Collection<V>>> mapFactory) {
|
||||
protected AbsCollValueMap(final Supplier<Map<K, Collection<V>>> mapFactory) {
|
||||
super(mapFactory);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
|
||||
*
|
||||
* @param map 提供初始数据的集合
|
||||
*/
|
||||
protected AbsCollValueMap(Map<K, Collection<V>> map) {
|
||||
protected AbsCollValueMap(final Map<K, Collection<V>> map) {
|
||||
super(new HashMap<>(map));
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
|
||||
* @return 是否成功添加
|
||||
*/
|
||||
@Override
|
||||
public boolean putAllValues(K key, Collection<V> coll) {
|
||||
public boolean putAllValues(final K key, final Collection<V> coll) {
|
||||
if (ObjUtil.isNull(coll)) {
|
||||
return false;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
|
||||
* @return 是否成功添加
|
||||
*/
|
||||
@Override
|
||||
public boolean putValue(K key, V value) {
|
||||
public boolean putValue(final K key, final V value) {
|
||||
return super.computeIfAbsent(key, k -> createCollection())
|
||||
.add(value);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
|
||||
* @return 是否成功删除
|
||||
*/
|
||||
@Override
|
||||
public boolean removeValue(K key, V value) {
|
||||
public boolean removeValue(final K key, final V value) {
|
||||
return Opt.ofNullable(super.get(key))
|
||||
.map(t -> t.remove(value))
|
||||
.orElse(false);
|
||||
@@ -118,11 +118,11 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
|
||||
* @return 是否成功删除
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAllValues(K key, Collection<V> values) {
|
||||
public boolean removeAllValues(final K key, final Collection<V> values) {
|
||||
if (CollUtil.isEmpty(values)) {
|
||||
return false;
|
||||
}
|
||||
Collection<V> coll = get(key);
|
||||
final Collection<V> coll = get(key);
|
||||
return ObjUtil.isNotNull(coll) && coll.removeAll(values);
|
||||
}
|
||||
|
||||
@@ -133,10 +133,10 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
|
||||
* @return 当前实例
|
||||
*/
|
||||
@Override
|
||||
public MultiValueMap<K, V> filterAllValues(BiPredicate<K, V> filter) {
|
||||
public MultiValueMap<K, V> filterAllValues(final BiPredicate<K, V> filter) {
|
||||
entrySet().forEach(e -> {
|
||||
K k = e.getKey();
|
||||
Collection<V> coll = e.getValue().stream()
|
||||
final K k = e.getKey();
|
||||
final Collection<V> coll = e.getValue().stream()
|
||||
.filter(v -> filter.test(k, v))
|
||||
.collect(Collectors.toCollection(this::createCollection));
|
||||
e.setValue(coll);
|
||||
@@ -151,10 +151,10 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
|
||||
* @return 当前实例
|
||||
*/
|
||||
@Override
|
||||
public MultiValueMap<K, V> replaceAllValues(BiFunction<K, V, V> operate) {
|
||||
public MultiValueMap<K, V> replaceAllValues(final BiFunction<K, V, V> operate) {
|
||||
entrySet().forEach(e -> {
|
||||
K k = e.getKey();
|
||||
Collection<V> coll = e.getValue().stream()
|
||||
final K k = e.getKey();
|
||||
final Collection<V> coll = e.getValue().stream()
|
||||
.map(v -> operate.apply(k, v))
|
||||
.collect(Collectors.toCollection(this::createCollection));
|
||||
e.setValue(coll);
|
||||
|
@@ -14,6 +14,7 @@ import java.util.function.Predicate;
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class Graph<T> extends SetValueMap<T, T> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 添加边
|
||||
|
@@ -3,7 +3,6 @@ package cn.hutool.core.thread;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -70,6 +69,7 @@ public class SyncFinisher implements Closeable {
|
||||
* @param runnable 工作线程
|
||||
* @return this
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public SyncFinisher addRepeatWorker(final Runnable runnable) {
|
||||
for (int i = 0; i < this.threadSize; i++) {
|
||||
addWorker(new Worker() {
|
||||
@@ -197,7 +197,7 @@ public class SyncFinisher implements Closeable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void close() {
|
||||
stop();
|
||||
}
|
||||
|
||||
|
@@ -593,7 +593,7 @@ public class AnnotatedElementUtilTest {
|
||||
private @interface Annotation4 {}
|
||||
|
||||
@Annotation4
|
||||
private static class Super {};
|
||||
private static class Super {}
|
||||
|
||||
// ================= interface =================
|
||||
|
||||
@@ -608,7 +608,7 @@ public class AnnotatedElementUtilTest {
|
||||
private @interface Annotation6 {}
|
||||
|
||||
@Annotation6
|
||||
private interface Interface {};
|
||||
private interface Interface {}
|
||||
|
||||
// ================= foo =================
|
||||
|
||||
|
@@ -115,6 +115,6 @@ public class GenericAnnotationMappingTest {
|
||||
}
|
||||
|
||||
@Annotation1("foo")
|
||||
private static class Foo {};
|
||||
private static class Foo {}
|
||||
|
||||
}
|
||||
|
@@ -203,6 +203,6 @@ public class HierarchicalAnnotatedElementTest {
|
||||
public String method() { return null; }
|
||||
@Annotation1
|
||||
public static String method2() { return null; }
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -211,6 +211,6 @@ public class MetaAnnotatedElementTest {
|
||||
|
||||
@Annotation3(name = "foo")
|
||||
@Annotation4("foo")
|
||||
private static class Foo {};
|
||||
private static class Foo {}
|
||||
|
||||
}
|
||||
|
@@ -296,6 +296,6 @@ public class ResolvedAnnotationMappingTest {
|
||||
@Annotation3(value = "Annotation3", alias = 312)
|
||||
@Annotation2(value = "Annotation2")
|
||||
@Annotation1(value = "Annotation1", alias = "goo", unDefVal = "foo", unDefVal2 = "foo")
|
||||
private static class Foo {};
|
||||
private static class Foo {}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.core.codec;
|
||||
|
||||
import cn.hutool.core.codec.BaseN.Base32;
|
||||
import cn.hutool.core.codec.binary.Base32;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import org.junit.Assert;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.core.codec;
|
||||
|
||||
import cn.hutool.core.codec.BaseN.Base58;
|
||||
import cn.hutool.core.codec.binary.Base58;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.core.codec;
|
||||
|
||||
import cn.hutool.core.codec.BaseN.Base62;
|
||||
import cn.hutool.core.codec.binary.Base62;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.core.codec;
|
||||
|
||||
import cn.hutool.core.codec.BaseN.Base64;
|
||||
import cn.hutool.core.codec.binary.Base64;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
@@ -152,7 +152,9 @@ public class CollStreamUtilTest {
|
||||
|
||||
// 对null友好
|
||||
final Map<Long, Map<Long, Student>> termIdClassIdStudentMap = CollStreamUtil.group2Map(Arrays.asList(null, new Student(2, 2, 1, "王五")), Student::getTermId, Student::getClassId);
|
||||
final Map<Long, Map<Long, Student>> termIdClassIdStudentCompareMap = new HashMap<Long, Map<Long, Student>>() {{
|
||||
final Map<Long, Map<Long, Student>> termIdClassIdStudentCompareMap = new HashMap<Long, Map<Long, Student>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put(null, MapUtil.empty());
|
||||
put(2L, MapUtil.of(2L, new Student(2, 2, 1, "王五")));
|
||||
}};
|
||||
@@ -269,6 +271,7 @@ public class CollStreamUtilTest {
|
||||
Assert.assertEquals(set, compare);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Test
|
||||
public void testMerge() {
|
||||
Map<Long, Student> map1 = null;
|
||||
|
@@ -152,8 +152,8 @@ public class NumberChineseFormatterTest {
|
||||
|
||||
@Test
|
||||
public void formatTest3() {
|
||||
// String f1 = NumberChineseFormatter.format(5000_8000, false, false);
|
||||
// Assert.assertEquals("五千万零八千", f1);
|
||||
final String f1 = NumberChineseFormatter.format(5000_8000, false, false);
|
||||
Assert.assertEquals("五千万零八千", f1);
|
||||
|
||||
final String f2 = NumberChineseFormatter.format(1_0035_0089, false, false);
|
||||
Assert.assertEquals("一亿零三十五万零八十九", f2);
|
||||
|
@@ -28,7 +28,7 @@ public class NioUtilTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void copyByNIOTest2() throws IOException {
|
||||
public void copyByNIOTest2() {
|
||||
final File file = FileUtil.file("d:/test/logo.jpg");
|
||||
final BufferedInputStream in = FileUtil.getInputStream(file);
|
||||
final BufferedOutputStream out = FileUtil.getOutputStream("d:/test/2logo.jpg");
|
||||
|
@@ -11,12 +11,14 @@ import java.util.Map;
|
||||
|
||||
public class AssertTest {
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Test
|
||||
public void isNullTest() {
|
||||
final String a = null;
|
||||
Assert.isNull(a);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Test
|
||||
public void notNullTest() {
|
||||
final String a = null;
|
||||
@@ -113,10 +115,9 @@ public class AssertTest {
|
||||
Assert.isTrue(i > 0, () -> new IndexOutOfBoundsException("relation message to return"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
//String a="ab";
|
||||
//final String b = new String("abc");
|
||||
final String a = null;
|
||||
final String b = null;
|
||||
Assert.equals(a, b);
|
||||
@@ -124,18 +125,16 @@ public class AssertTest {
|
||||
Assert.equals(a, b, () -> new RuntimeException(StrUtil.format("{}和{}不相等", a, b)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Test
|
||||
public void notEqualsTest() {
|
||||
//String c="19";
|
||||
//final String d = new String("19");
|
||||
final String c = null;
|
||||
final String d = "null";
|
||||
//Assert.notEquals(c,d);
|
||||
//Assert.notEquals(c,d,"{}等于{}",c,d);
|
||||
Assert.notEquals(c, d, () -> new RuntimeException(StrUtil.format("{}和{}相等", c, d)));
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Test
|
||||
public void notEqualsTest2() {
|
||||
final Object c = null;
|
||||
|
@@ -162,16 +162,25 @@ public class EntryStreamTest {
|
||||
|
||||
@Test
|
||||
public void testAppend() {
|
||||
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){{
|
||||
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){
|
||||
private static final long serialVersionUID = 2091911960221937275L;
|
||||
|
||||
{
|
||||
put(1, 1);
|
||||
put(2, 2);
|
||||
}};
|
||||
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){{
|
||||
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){
|
||||
private static final long serialVersionUID = 4802315578432177802L;
|
||||
|
||||
{
|
||||
put(3, 3);
|
||||
put(4, 4);
|
||||
}};
|
||||
Assert.assertEquals(
|
||||
new ArrayList<Map.Entry<Integer, Integer>>(){{
|
||||
new ArrayList<Map.Entry<Integer, Integer>>(){
|
||||
private static final long serialVersionUID = -4045530648496761947L;
|
||||
|
||||
{
|
||||
addAll(map1.entrySet());
|
||||
addAll(map2.entrySet());
|
||||
}},
|
||||
@@ -184,16 +193,25 @@ public class EntryStreamTest {
|
||||
|
||||
@Test
|
||||
public void testPrepend() {
|
||||
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){{
|
||||
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){
|
||||
private static final long serialVersionUID = -8772310525807986780L;
|
||||
|
||||
{
|
||||
put(1, 1);
|
||||
put(2, 2);
|
||||
}};
|
||||
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){{
|
||||
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){
|
||||
private static final long serialVersionUID = -8453400649627773936L;
|
||||
|
||||
{
|
||||
put(3, 3);
|
||||
put(4, 4);
|
||||
}};
|
||||
Assert.assertEquals(
|
||||
new ArrayList<Map.Entry<Integer, Integer>>(){{
|
||||
new ArrayList<Map.Entry<Integer, Integer>>(){
|
||||
private static final long serialVersionUID = 7564826138581563332L;
|
||||
|
||||
{
|
||||
addAll(map2.entrySet());
|
||||
addAll(map1.entrySet());
|
||||
}},
|
||||
@@ -254,7 +272,7 @@ public class EntryStreamTest {
|
||||
map.put(1, 1);
|
||||
map.put(2, 2);
|
||||
map.put(3, 3);
|
||||
List<Integer> keys = EntryStream.of(map).collectKeys(Collectors.toList());
|
||||
final List<Integer> keys = EntryStream.of(map).collectKeys(Collectors.toList());
|
||||
Assert.assertEquals(new ArrayList<>(map.keySet()), keys);
|
||||
}
|
||||
|
||||
@@ -264,7 +282,7 @@ public class EntryStreamTest {
|
||||
map.put(1, 1);
|
||||
map.put(2, 2);
|
||||
map.put(3, 3);
|
||||
List<Integer> keys = EntryStream.of(map).collectValues(Collectors.toList());
|
||||
final List<Integer> keys = EntryStream.of(map).collectValues(Collectors.toList());
|
||||
Assert.assertEquals(new ArrayList<>(map.keySet()), keys);
|
||||
}
|
||||
|
||||
@@ -324,7 +342,7 @@ public class EntryStreamTest {
|
||||
map.put(1, 1);
|
||||
map.put(2, 2);
|
||||
map.put(3, 3);
|
||||
List<Integer> list = EntryStream.of(map)
|
||||
final List<Integer> list = EntryStream.of(map)
|
||||
.flatMap(e -> Stream.of(e.getKey(), e.getKey() + 1))
|
||||
.collect(Collectors.toList());
|
||||
Assert.assertEquals(Arrays.asList(1, 2, 2, 3, 3, 4), list);
|
||||
@@ -567,7 +585,7 @@ public class EntryStreamTest {
|
||||
private final K key;
|
||||
private final V value;
|
||||
|
||||
public Entry(K key, V value) {
|
||||
public Entry(final K key, final V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
@@ -583,7 +601,7 @@ public class EntryStreamTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
public V setValue(final V value) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class ObjUtilTest {
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
Object a = null;
|
||||
@@ -109,6 +110,7 @@ public class ObjUtilTest {
|
||||
Assert.assertFalse(ObjUtil.isNotEmpty(Collections.emptyIterator()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Test
|
||||
public void defaultIfNullTest() {
|
||||
final Object val1 = new Object();
|
||||
@@ -227,7 +229,7 @@ public class ObjUtilTest {
|
||||
private final Integer id;
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
throw new RuntimeException("can not clone this object");
|
||||
throw new CloneNotSupportedException("can not clone this object");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,6 +257,6 @@ public class ObjUtilTest {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private interface TypeArgument<A, B> {};
|
||||
private interface TypeArgument<A, B> {}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user