mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add SetUtil
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -19,7 +19,7 @@ public class IssueI1AU86Test {
|
||||
|
||||
@Test
|
||||
public void toListTest() {
|
||||
final List<String> redisList = CollUtil.newArrayList(
|
||||
final List<String> redisList = ListUtil.toList(
|
||||
"{\"updateDate\":1583376342000,\"code\":\"move\",\"id\":1,\"sort\":1,\"name\":\"电影大全\"}",
|
||||
"{\"updateDate\":1583378882000,\"code\":\"zy\",\"id\":3,\"sort\":5,\"name\":\"综艺会\"}"
|
||||
);
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.convert.ConvertException;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
@@ -98,7 +97,7 @@ public class JSONArrayTest {
|
||||
b2.setAkey("aValue2");
|
||||
b2.setBkey("bValue2");
|
||||
|
||||
final ArrayList<KeyBean> list = CollUtil.newArrayList(b1, b2);
|
||||
final ArrayList<KeyBean> list = ListUtil.toList(b1, b2);
|
||||
|
||||
final JSONArray jsonArray = JSONUtil.parseArray(list);
|
||||
Assert.assertEquals("aValue1", jsonArray.getJSONObject(0).getStr("akey"));
|
||||
|
@@ -2,7 +2,7 @@ package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
import cn.hutool.core.annotation.PropIgnore;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
@@ -238,7 +238,7 @@ public class JSONObjectTest {
|
||||
userA.setA("A user");
|
||||
userA.setName("{\n\t\"body\":{\n\t\t\"loginId\":\"id\",\n\t\t\"password\":\"pwd\"\n\t}\n}");
|
||||
userA.setDate(new Date());
|
||||
userA.setSqs(CollUtil.newArrayList(new Seq("seq1"), new Seq("seq2")));
|
||||
userA.setSqs(ListUtil.toList(new Seq("seq1"), new Seq("seq2")));
|
||||
|
||||
final JSONObject json = JSONUtil.parseObj(userA);
|
||||
final UserA userA2 = json.toBean(UserA.class);
|
||||
@@ -320,7 +320,7 @@ public class JSONObjectTest {
|
||||
final UserA userA = new UserA();
|
||||
userA.setName("nameTest");
|
||||
userA.setDate(new Date());
|
||||
userA.setSqs(CollUtil.newArrayList(new Seq(null), new Seq("seq2")));
|
||||
userA.setSqs(ListUtil.toList(new Seq(null), new Seq("seq2")));
|
||||
|
||||
final JSONObject json = JSONUtil.parseObj(userA, false);
|
||||
|
||||
@@ -333,7 +333,7 @@ public class JSONObjectTest {
|
||||
final TestBean bean = new TestBean();
|
||||
bean.setDoubleValue(111.1);
|
||||
bean.setIntValue(123);
|
||||
bean.setList(CollUtil.newArrayList("a", "b", "c"));
|
||||
bean.setList(ListUtil.toList("a", "b", "c"));
|
||||
bean.setStrValue("strTest");
|
||||
bean.setTestEnum(TestEnum.TYPE_B);
|
||||
|
||||
@@ -565,7 +565,7 @@ public class JSONObjectTest {
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeStatic"})
|
||||
public static class SameNameBean {
|
||||
private final String username = "123";
|
||||
private final String userName = "abc";
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
@@ -59,7 +58,7 @@ public class JSONUtilTest {
|
||||
a2.setDate(DateUtil.date());
|
||||
a2.setName("AAAA222Name");
|
||||
|
||||
final ArrayList<UserA> list = CollUtil.newArrayList(a1, a2);
|
||||
final ArrayList<UserA> list = ListUtil.toList(a1, a2);
|
||||
final HashMap<String, Object> map = MapUtil.newHashMap();
|
||||
map.put("total", 13);
|
||||
map.put("rows", list);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -24,12 +24,12 @@ public class ParseBeanTest {
|
||||
c2.setTest("test2");
|
||||
|
||||
final B b1 = new B();
|
||||
b1.setCs(CollUtil.newArrayList(c1, c2));
|
||||
b1.setCs(ListUtil.toList(c1, c2));
|
||||
final B b2 = new B();
|
||||
b2.setCs(CollUtil.newArrayList(c1, c2));
|
||||
b2.setCs(ListUtil.toList(c1, c2));
|
||||
|
||||
final A a = new A();
|
||||
a.setBs(CollUtil.newArrayList(b1, b2));
|
||||
a.setBs(ListUtil.toList(b1, b2));
|
||||
|
||||
final JSONObject json = JSONUtil.parseObj(a);
|
||||
final A a1 = JSONUtil.toBean(json, A.class);
|
||||
|
Reference in New Issue
Block a user