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
183a820206
commit
76d95d44a8
@ -285,7 +285,7 @@ public class BeanDesc implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 包括boolean的任何类型只有一种匹配情况:name -》 getName
|
// 包括boolean的任何类型只有一种匹配情况:name -》 getName
|
||||||
return methodName.equals("get" + fieldName);
|
return methodName.equals("get" + handledFieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,10 +322,10 @@ public class BeanDesc implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 针对Boolean类型特殊检查
|
// 针对Boolean类型特殊检查
|
||||||
if (isBooleanField && handledFieldName.startsWith("is")) {
|
if (isBooleanField && fieldName.startsWith("is")) {
|
||||||
// 字段是is开头
|
// 字段是is开头
|
||||||
if (methodName.equals("set" + StrUtil.removePrefix(fieldName, "is"))// isName -》 setName
|
if (methodName.equals("set" + StrUtil.removePrefix(fieldName, "is"))// isName -》 setName
|
||||||
|| methodName.equals("set" + fieldName)// isName -》 setIsName
|
|| methodName.equals("set" + handledFieldName)// isName -》 setIsName
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,6 @@ public class JSONObjectTest {
|
|||||||
@Test
|
@Test
|
||||||
public void toBeanWithNullTest() {
|
public void toBeanWithNullTest() {
|
||||||
String jsonStr = "{'data':{'userName':'ak','password': null}}";
|
String jsonStr = "{'data':{'userName':'ak','password': null}}";
|
||||||
Console.log(JSONUtil.parseObj(jsonStr));
|
|
||||||
UserWithMap user = JSONUtil.toBean(JSONUtil.parseObj(jsonStr), UserWithMap.class);
|
UserWithMap user = JSONUtil.toBean(JSONUtil.parseObj(jsonStr), UserWithMap.class);
|
||||||
Assert.assertTrue(user.getData().containsKey("password"));
|
Assert.assertTrue(user.getData().containsKey("password"));
|
||||||
}
|
}
|
||||||
@ -518,7 +517,7 @@ public class JSONObjectTest {
|
|||||||
final Map.Entry<String, String> next = entries.iterator().next();
|
final Map.Entry<String, String> next = entries.iterator().next();
|
||||||
|
|
||||||
final JSONObject jsonObject = JSONUtil.parseObj(next);
|
final JSONObject jsonObject = JSONUtil.parseObj(next);
|
||||||
Console.log(jsonObject);
|
Assert.assertEquals("{\"test\":\"testValue\"}", jsonObject.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = JSONException.class)
|
@Test(expected = JSONException.class)
|
||||||
@ -533,7 +532,7 @@ public class JSONObjectTest {
|
|||||||
map.put("c", 2.0F);
|
map.put("c", 2.0F);
|
||||||
|
|
||||||
final String s = JSONUtil.toJsonStr(map);
|
final String s = JSONUtil.toJsonStr(map);
|
||||||
Console.log(s);
|
Assert.assertEquals("{\"c\":2}", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user