This commit is contained in:
Looly
2023-03-13 11:41:20 +08:00
parent 0df74202c2
commit 1ad628f944
25 changed files with 59 additions and 54 deletions

View File

@@ -28,7 +28,7 @@ public interface AnnotationMapping<T extends Annotation> extends Annotation {
T getAnnotation();
/**
* 根据当前映射对象,通过动态代理生成一个类型与被包装注解对象一致合成注解,该注解相对原生注解:
* 根据当前映射对象,通过动态代理生成一个类型与被包装注解对象一致合成注解,该注解相对原生注解:
* <ul>
* <li>支持同注解内通过{@link Alias}构建的别名机制;</li>
* <li>支持子注解对元注解的同名同类型属性覆盖机制;</li>

View File

@@ -73,7 +73,7 @@ public class BetweenFormatter implements Serializable {
final int level = this.level.ordinal();
int levelCount = 0;
if (isLevelCountValid(levelCount) && 0 != day && level >= Level.DAY.ordinal()) {
if (isLevelCountValid(levelCount) && 0 != day) {
sb.append(day).append(Level.DAY.name);
levelCount++;
}

View File

@@ -15,6 +15,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -246,7 +247,7 @@ public class FileReader extends FileWrapper {
*/
public BufferedInputStream getInputStream() throws IORuntimeException {
try {
return new BufferedInputStream(new FileInputStream(this.file));
return new BufferedInputStream(Files.newInputStream(this.file.toPath()));
} catch (final IOException e) {
throw new IORuntimeException(e);
}

View File

@@ -123,6 +123,7 @@ public class ResourceUtil {
*
* @param resource 资源相对Classpath的路径
* @return 资源URL
* @throws IORuntimeException IO异常
*/
public static URL getResourceUrl(final String resource) throws IORuntimeException {
return getResourceUrl(resource, null);

View File

@@ -24,7 +24,7 @@ import java.util.function.Predicate;
* </table>
*
* <p>空区间</p>
* <p>根据数学定义,当区间中无任何实数时,认为该区间代表的集合为空集,
* <p>根据数学定义,当区间中无任何实数时,认为该区间 代表的集合为空集,
* 用户可通过{@link #isEmpty}确认当前实例是否为空区间。<br>
* 若实例上界<em>a</em>,下界为<em>b</em>,则当实例满足下述任意条件时,认为其为一个空区间:
* <ul>

View File

@@ -254,6 +254,7 @@ public interface TerminableWrappedStream<T, S extends TerminableWrappedStream<T,
* @param predicate 断言
* @return 与给定断言匹配的第一个元素的下标,如果不存在则返回-1
*/
@SuppressWarnings("ResultOfMethodCallIgnored")
default int findFirstIdx(final Predicate<? super T> predicate) {
Objects.requireNonNull(predicate);
if (isParallel()) {
@@ -263,7 +264,7 @@ public interface TerminableWrappedStream<T, S extends TerminableWrappedStream<T,
unwrap().filter(e -> {
index.increment();
return predicate.test(e);
}).findFirst();
}).findFirst();// 此处只做计数,不需要值
return index.get();
}
}

View File

@@ -428,7 +428,7 @@ public class AntPathMatcher {
}
/**
* Test whether or not a string matches against a pattern.
* Test whether a string matches against a pattern.
*
* @param pattern the pattern to match against (never {@code null})
* @param str the String which must be matched against the pattern (never {@code null})

View File

@@ -89,7 +89,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
* 数组是否为非空<br>
* 此方法会匹配单一对象,如果此对象为{@code null}则返回false<br>
* 如果此对象为非数组理解为此对象为数组的第一个元素则返回true<br>
* 如果此对象为数组对象数组长度大于0情况下返回true否则返回false
* 如果此对象为数组对象数组长度大于0情况下返回true否则返回false
*
* @param array 数组
* @return 是否为非空

View File

@@ -280,6 +280,7 @@ public class StrUtilTest {
Assert.assertEquals("ghigh", pre);
}
@SuppressWarnings("SimplifiableAssertion")
@Test
public void subPreTest() {
Assert.assertEquals(StrUtil.subPre(null, 3), null);

View File

@@ -216,7 +216,7 @@ public class ArrayUtilTest {
final String[] a = {"1", "2", "3", "4"};
final String[] b = {"a", "b", "c"};
// 在-1位置插入相当于在3位置插入
// 在-1位置插入相当于在3位置插入
String[] result = ArrayUtil.insert(a, -1, b);
Assert.assertArrayEquals(new String[]{"1", "2", "3", "a", "b", "c", "4"}, result);
@@ -232,7 +232,7 @@ public class ArrayUtilTest {
result = ArrayUtil.insert(a, 4, b);
Assert.assertArrayEquals(new String[]{"1", "2", "3", "4", "a", "b", "c"}, result);
// 在第5个位置插入由于数组长度为4因此补null
// 在第5个位置插入由于数组长度为4因此补null
result = ArrayUtil.insert(a, 5, b);
Assert.assertArrayEquals(new String[]{"1", "2", "3", "4", null, "a", "b", "c"}, result);
}
@@ -472,7 +472,7 @@ public class ArrayUtilTest {
final String[] a = {"1", "2", "3", "4"};
final String[] b = {"a", "b", "c"};
// 在小于0的位置-1位置插入返回b+a新数组
// 在小于0的位置-1位置插入返回b+a新数组
String[] result = ArrayUtil.replace(a, -1, b);
Assert.assertArrayEquals(new String[]{"a", "b", "c", "1", "2", "3", "4"}, result);

View File

@@ -2,8 +2,8 @@ package cn.hutool.core.util;
import cn.hutool.core.compress.ZipReader;
import cn.hutool.core.compress.ZipUtil;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.text.StrUtil;
import org.junit.Assert;
@@ -11,11 +11,12 @@ import org.junit.Ignore;
import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipFile;
@@ -156,7 +157,7 @@ public class ZipUtilTest {
//https://github.com/dromara/hutool/issues/944
final String dir = "d:/test";
final String zip = "d:/test.zip";
try (final OutputStream out = new FileOutputStream(zip)){
try (final OutputStream out = Files.newOutputStream(Paths.get(zip))){
//实际应用中, out 为 HttpServletResponse.getOutputStream
ZipUtil.zip(out, Charset.defaultCharset(), false, null, new File(dir));
} catch (final IOException e) {