iterable, CharSequence conjunction, String prefix, String suffix) {
if (null == iterable) {
return null;
diff --git a/hutool-core/src/main/java/cn/hutool/core/date/ChineseDate.java b/hutool-core/src/main/java/cn/hutool/core/date/ChineseDate.java
index 09655aa72..09622ddd3 100644
--- a/hutool-core/src/main/java/cn/hutool/core/date/ChineseDate.java
+++ b/hutool-core/src/main/java/cn/hutool/core/date/ChineseDate.java
@@ -19,16 +19,16 @@ public class ChineseDate {
private static final Date baseDate = DateUtil.parseDate("1900-01-31");
//农历年
- private int year;
+ private final int year;
//农历月
- private int month;
+ private final int month;
//农历日
- private int day;
+ private final int day;
//是否闰年
private boolean leap;
- private String[] chineseNumber = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"};
- private String[] chineseNumberName = {"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"};
- private long[] lunarInfo = new long[]{0x04bd8, 0x04ae0, 0x0a570,
+ private final String[] chineseNumber = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"};
+ private final String[] chineseNumberName = {"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"};
+ private final long[] lunarInfo = new long[]{0x04bd8, 0x04ae0, 0x0a570,
0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0,
0x0ada2, 0x095b0, 0x14977, 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50,
@@ -51,7 +51,7 @@ public class ChineseDate {
0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0, 0x056d0, 0x055b2,
0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0};
//农历节日 *表示放假日
- private String[] lFtv = new String[]{
+ private final String[] lFtv = new String[]{
"0101 春节", "0102 大年初二", "0103 大年初三", "0104 大年初四",
"0105 大年初五", "0106 大年初六", "0107 大年初七", "0105 路神生日",
"0115 元宵节", "0202 龙抬头", "0219 观世音圣诞", "0404 寒食节",
diff --git a/hutool-core/src/main/java/cn/hutool/core/io/FastByteArrayOutputStream.java b/hutool-core/src/main/java/cn/hutool/core/io/FastByteArrayOutputStream.java
index f1b498508..a27cace9d 100644
--- a/hutool-core/src/main/java/cn/hutool/core/io/FastByteArrayOutputStream.java
+++ b/hutool-core/src/main/java/cn/hutool/core/io/FastByteArrayOutputStream.java
@@ -1,11 +1,11 @@
package cn.hutool.core.io;
+import cn.hutool.core.util.CharsetUtil;
+
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
-import cn.hutool.core.util.CharsetUtil;
-
/**
* 基于快速缓冲FastByteBuffer的OutputStream,随着数据的增长自动扩充缓冲区
*
@@ -34,7 +34,6 @@ public class FastByteArrayOutputStream extends OutputStream {
buffer = new FastByteBuffer(size);
}
- @SuppressWarnings("NullableProblems")
@Override
public void write(byte[] b, int off, int len) {
buffer.append(b, off, len);
diff --git a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java
index 67cf26783..1c011f6f7 100644
--- a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java
+++ b/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java
@@ -2402,7 +2402,7 @@ public class ArrayUtil {
if (ArrayUtil.isArray(item)) {
sb.append(join(ArrayUtil.wrap(item), conjunction, prefix, suffix));
} else if (item instanceof Iterable>) {
- sb.append(IterUtil.join((Iterable>) item, conjunction, prefix, suffix));
+ sb.append(CollUtil.join((Iterable>) item, conjunction, prefix, suffix));
} else if (item instanceof Iterator>) {
sb.append(IterUtil.join((Iterator>) item, conjunction, prefix, suffix));
} else {
diff --git a/hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java
index 39b7335b2..36544e68d 100644
--- a/hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java
+++ b/hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java
@@ -938,7 +938,6 @@ public class ZipUtil {
addDir(subPath, out);
}
// 压缩目录下的子文件或目录
- //noinspection ConstantConditions
for (File childFile : files) {
zip(childFile, srcRootDir, out, filter);
}
diff --git a/hutool-core/src/test/java/cn/hutool/core/clone/CloneTest.java b/hutool-core/src/test/java/cn/hutool/core/clone/CloneTest.java
index e7f7f165d..569a32994 100644
--- a/hutool-core/src/test/java/cn/hutool/core/clone/CloneTest.java
+++ b/hutool-core/src/test/java/cn/hutool/core/clone/CloneTest.java
@@ -1,5 +1,7 @@
package cn.hutool.core.clone;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import org.junit.Assert;
import org.junit.Test;
@@ -17,7 +19,10 @@ public class CloneTest {
Cat cat = new Cat();
Cat cat2 = cat.clone();
Assert.assertEquals(cat, cat2);
-
+ }
+
+ @Test
+ public void cloneTest2(){
//继承CloneSupport类
Dog dog = new Dog();
Dog dog2 = dog.clone();
@@ -30,7 +35,8 @@ public class CloneTest {
* @author Looly
*
*/
- private static class Cat implements Cloneable{
+ @Data
+ static class Cat implements Cloneable{
private String name = "miaomiao";
private int age = 2;
@@ -42,35 +48,6 @@ public class CloneTest {
throw new CloneRuntimeException(e);
}
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + age;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Cat other = (Cat) obj;
- if (age != other.age) {
- return false;
- }
- if (name == null) {
- return other.name == null;
- } else return name.equals(other.name);
- }
}
/**
@@ -78,37 +55,10 @@ public class CloneTest {
* @author Looly
*
*/
- private static class Dog extends CloneSupport{
+ @EqualsAndHashCode(callSuper = false)
+ @Data
+ static class Dog extends CloneSupport{
private String name = "wangwang";
private int age = 3;
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + age;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Dog other = (Dog) obj;
- if (age != other.age) {
- return false;
- }
- if (name == null) {
- return other.name == null;
- } else return name.equals(other.name);
- }
}
}
diff --git a/hutool-core/src/test/java/cn/hutool/core/collection/CollUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/collection/CollUtilTest.java
index 85427b99a..c6f6190fe 100644
--- a/hutool-core/src/test/java/cn/hutool/core/collection/CollUtilTest.java
+++ b/hutool-core/src/test/java/cn/hutool/core/collection/CollUtilTest.java
@@ -179,6 +179,7 @@ public class CollUtilTest {
map.put("c", "3");
final String[] result = new String[1];
+ //noinspection deprecation
CollUtil.forEach(map, (key, value, index) -> {
if (key.equals("a")) {
result[0] = value;
diff --git a/hutool-core/src/test/java/cn/hutool/core/collection/IterUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/collection/IterUtilTest.java
index f5eabd172..a516536bf 100644
--- a/hutool-core/src/test/java/cn/hutool/core/collection/IterUtilTest.java
+++ b/hutool-core/src/test/java/cn/hutool/core/collection/IterUtilTest.java
@@ -16,25 +16,25 @@ public class IterUtilTest {
@Test
public void fieldValueMapTest() {
ArrayList carList = CollUtil.newArrayList(new Car("123", "大众"), new Car("345", "奔驰"), new Car("567", "路虎"));
- Map carNameMap = IterUtil.fieldValueMap(carList, "carNumber");
-
+ Map carNameMap = IterUtil.fieldValueMap(carList.iterator(), "carNumber");
+
Assert.assertEquals("大众", carNameMap.get("123").getCarName());
Assert.assertEquals("奔驰", carNameMap.get("345").getCarName());
Assert.assertEquals("路虎", carNameMap.get("567").getCarName());
}
-
+
@Test
public void joinTest() {
ArrayList list = CollUtil.newArrayList("1", "2", "3", "4");
- String join = IterUtil.join(list, ":");
+ String join = IterUtil.join(list.iterator(), ":");
Assert.assertEquals("1:2:3:4", join);
ArrayList list1 = CollUtil.newArrayList(1, 2, 3, 4);
- String join1 = IterUtil.join(list1, ":");
+ String join1 = IterUtil.join(list1.iterator(), ":");
Assert.assertEquals("1:2:3:4", join1);
ArrayList list2 = CollUtil.newArrayList("1", "2", "3", "4");
- String join2 = IterUtil.join(list2, ":", "\"", "\"");
+ String join2 = IterUtil.join(list2.iterator(), ":", "\"", "\"");
Assert.assertEquals("\"1\":\"2\":\"3\":\"4\"", join2);
}
diff --git a/hutool-core/src/test/java/cn/hutool/core/convert/NumberWordFormatTest.java b/hutool-core/src/test/java/cn/hutool/core/convert/NumberWordFormatTest.java
index fdeb94091..8eafddea1 100644
--- a/hutool-core/src/test/java/cn/hutool/core/convert/NumberWordFormatTest.java
+++ b/hutool-core/src/test/java/cn/hutool/core/convert/NumberWordFormatTest.java
@@ -3,16 +3,14 @@ package cn.hutool.core.convert;
import org.junit.Assert;
import org.junit.Test;
-import cn.hutool.core.convert.NumberWordFormater;
-
public class NumberWordFormatTest {
@Test
public void formatTest() {
- String format = NumberWordFormater.format(100.23);
+ String format = NumberWordFormatter.format(100.23);
Assert.assertEquals("ONE HUNDRED AND CENTS TWENTY THREE ONLY", format);
- String format2 = NumberWordFormater.format("2100.00");
+ String format2 = NumberWordFormatter.format("2100.00");
Assert.assertEquals("TWO THOUSAND ONE HUNDRED AND CENTS ONLY", format2);
}
}
diff --git a/hutool-db/src/main/java/cn/hutool/db/ds/AbstractDSFactory.java b/hutool-db/src/main/java/cn/hutool/db/ds/AbstractDSFactory.java
index 387f0cc98..318a488d1 100644
--- a/hutool-db/src/main/java/cn/hutool/db/ds/AbstractDSFactory.java
+++ b/hutool-db/src/main/java/cn/hutool/db/ds/AbstractDSFactory.java
@@ -1,11 +1,5 @@
package cn.hutool.db.ds;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.sql.DataSource;
-
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.resource.NoResourceException;
import cn.hutool.core.lang.Assert;
@@ -15,6 +9,11 @@ import cn.hutool.db.DbUtil;
import cn.hutool.db.dialect.DriverUtil;
import cn.hutool.setting.Setting;
+import javax.sql.DataSource;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* 抽象数据源工厂
* 此工厂抽象类用于实现数据源的缓存,当用户多次调用{@link #getDataSource(String)} 时,工厂只需创建一次即可。
@@ -32,9 +31,9 @@ public abstract class AbstractDSFactory extends DSFactory {
private static final String DEFAULT_DB_SETTING_PATH2 = "db.setting";
/** 数据库连接配置文件 */
- private Setting setting;
+ private final Setting setting;
/** 数据源池 */
- private Map dsMap;
+ private final Map dsMap;
/**
* 构造
diff --git a/hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java b/hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java
index 43d50aaef..f8e917ab9 100644
--- a/hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java
+++ b/hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java
@@ -144,7 +144,7 @@ public class MetaUtil {
}
}
}
- return columnNames.toArray(new String[columnNames.size()]);
+ return columnNames.toArray(new String[0]);
} catch (Exception e) {
throw new DbRuntimeException("Get columns error!", e);
} finally {
@@ -172,7 +172,6 @@ public class MetaUtil {
* @param tableName 表名
* @return Table对象
*/
- @SuppressWarnings("resource")
public static Table getTableMeta(DataSource ds, String tableName) {
final Table table = Table.create(tableName);
Connection conn = null;
diff --git a/hutool-extra/src/test/java/cn/hutool/extra/template/BeetlUtilTest.java b/hutool-extra/src/test/java/cn/hutool/extra/template/BeetlUtilTest.java
index 342906c0c..c7d27f621 100644
--- a/hutool-extra/src/test/java/cn/hutool/extra/template/BeetlUtilTest.java
+++ b/hutool-extra/src/test/java/cn/hutool/extra/template/BeetlUtilTest.java
@@ -1,7 +1,7 @@
package cn.hutool.extra.template;
-import java.io.IOException;
-
+import cn.hutool.core.lang.Dict;
+import cn.hutool.extra.template.engine.beetl.BeetlUtil;
import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
@@ -9,8 +9,7 @@ import org.beetl.core.resource.StringTemplateResourceLoader;
import org.junit.Assert;
import org.junit.Test;
-import cn.hutool.core.lang.Dict;
-import cn.hutool.extra.template.engine.beetl.BeetlUtil;
+import java.io.IOException;
/**
* BeetlUtil单元测试
@@ -18,6 +17,7 @@ import cn.hutool.extra.template.engine.beetl.BeetlUtil;
* @author looly
*
*/
+@SuppressWarnings("deprecation")
public class BeetlUtilTest {
@Test
diff --git a/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java b/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java
index c6e735200..2730ec6d9 100644
--- a/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java
+++ b/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java
@@ -14,13 +14,14 @@ import org.junit.Test;
* @author looly
*
*/
-@SuppressWarnings("ConstantConditions")
public class RestTest {
@Test
public void contentTypeTest() {
HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/")//
- .body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2").toString());
+ .body(JSONUtil.createObj()
+ .set("aaa", "aaaValue")
+ .set("键2", "值2").toString());
Assert.assertEquals("application/json;charset=UTF-8", request.header("Content-Type"));
}
@@ -28,7 +29,9 @@ public class RestTest {
@Ignore
public void postTest() {
HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/")//
- .body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2").toString());
+ .body(JSONUtil.createObj()
+ .set("aaa", "aaaValue")
+ .set("键2", "值2").toString());
Console.log(request.execute().body());
}
@@ -36,7 +39,8 @@ public class RestTest {
@Ignore
public void postTest2() {
String result = HttpUtil.post("http://localhost:8090/rest/restTest/", JSONUtil.createObj()//
- .put("aaa", "aaaValue").put("键2", "值2").toString());
+ .set("aaa", "aaaValue")
+ .set("键2", "值2").toString());
Console.log(result);
}
@@ -44,7 +48,9 @@ public class RestTest {
@Ignore
public void postTest3() {
HttpRequest request = HttpRequest.post("http://211.162.39.204:8181/jeesite-simple/a/open/bizGwbnService/test")//
- .body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2").toString());
+ .body(JSONUtil.createObj()
+ .set("aaa", "aaaValue")
+ .set("键2", "值2").toString());
Console.log(request.execute().body());
}
}
diff --git a/hutool-json/src/main/java/cn/hutool/json/JSONArray.java b/hutool-json/src/main/java/cn/hutool/json/JSONArray.java
index da5abb041..f19764969 100644
--- a/hutool-json/src/main/java/cn/hutool/json/JSONArray.java
+++ b/hutool-json/src/main/java/cn/hutool/json/JSONArray.java
@@ -3,6 +3,7 @@ package cn.hutool.json;
import cn.hutool.core.bean.BeanPath;
import cn.hutool.core.collection.ArrayIter;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@@ -41,7 +42,7 @@ public class JSONArray implements JSON, JSONGetter, List