mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
fix code
This commit is contained in:
@@ -167,7 +167,7 @@ public class JSONObject extends MapWrapper<String, JSON> implements JSON, JSONGe
|
||||
return putValue(key, 1);
|
||||
}
|
||||
|
||||
if (json instanceof JSONPrimitive jsonPrimitive) {
|
||||
if (json instanceof final JSONPrimitive jsonPrimitive) {
|
||||
if (jsonPrimitive.isNumber()) {
|
||||
jsonPrimitive.increment();
|
||||
return this;
|
||||
|
||||
@@ -134,11 +134,11 @@ public class TemporalTypeAdapter implements MatcherJSONSerializer<TemporalAccess
|
||||
* @param json JSONObject
|
||||
*/
|
||||
private static void toJSONObject(final TemporalAccessor bean, final JSONObject json) {
|
||||
if (bean instanceof LocalDate localDate) {
|
||||
if (bean instanceof final LocalDate localDate) {
|
||||
json.putValue(YEAR_KEY, localDate.getYear());
|
||||
json.putValue(MONTH_KEY, localDate.getMonthValue());
|
||||
json.putValue(DAY_KEY, localDate.getDayOfMonth());
|
||||
} else if (bean instanceof LocalDateTime localDateTime) {
|
||||
} else if (bean instanceof final LocalDateTime localDateTime) {
|
||||
json.putValue(YEAR_KEY, localDateTime.getYear());
|
||||
json.putValue(MONTH_KEY, localDateTime.getMonthValue());
|
||||
json.putValue(DAY_KEY, localDateTime.getDayOfMonth());
|
||||
@@ -146,7 +146,7 @@ public class TemporalTypeAdapter implements MatcherJSONSerializer<TemporalAccess
|
||||
json.putValue(MINUTE_KEY, localDateTime.getMinute());
|
||||
json.putValue(SECOND_KEY, localDateTime.getSecond());
|
||||
json.putValue(NANO_KEY, localDateTime.getNano());
|
||||
} else if (bean instanceof LocalTime localTime) {
|
||||
} else if (bean instanceof final LocalTime localTime) {
|
||||
json.putValue(HOUR_KEY, localTime.getHour());
|
||||
json.putValue(MINUTE_KEY, localTime.getMinute());
|
||||
json.putValue(SECOND_KEY, localTime.getSecond());
|
||||
|
||||
@@ -48,7 +48,7 @@ public class JSONNodeBeanFactory implements NodeBeanFactory<JSON> {
|
||||
final BeanPath<JSON> next = beanPath.next();
|
||||
if (null != next) {
|
||||
final Node node = next.getNode();
|
||||
if (node instanceof NameNode nameNode) {
|
||||
if (node instanceof final NameNode nameNode) {
|
||||
if (nameNode.isNumber()) {
|
||||
return JSONUtil.ofArray(config);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Issue3289Test {
|
||||
@Test
|
||||
void parseTest() {
|
||||
Assertions.assertThrows(JSONException.class, () -> {
|
||||
String s = "{\"G\":00,[6E962756779]}";
|
||||
final String s = "{\"G\":00,[6E962756779]}";
|
||||
JSONUtil.parse(s);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class IssueID61QRTest {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testName() {
|
||||
JSONObject map1 = JSONUtil.ofObj(new JSONConfig().setDateFormat("yyyy"));
|
||||
final JSONObject map1 = JSONUtil.ofObj(new JSONConfig().setDateFormat("yyyy"));
|
||||
map1.putValue("a", 3);
|
||||
map1.putValue("b", 5);
|
||||
map1.putValue("c", 5432);
|
||||
|
||||
@@ -28,9 +28,9 @@ public class Issue4105Test {
|
||||
void verifyNoneTest() {
|
||||
// {"alg": "none"}.{"exp": 1642196407}
|
||||
// 当定义alg为none时,校验总是成功
|
||||
String head = Base64.encode("{\"alg\": \"none\"}");
|
||||
String payload = Base64.encode("{\"exp\": 1642196407}");
|
||||
String token = StrUtil.format("{}.{}.", head, payload);
|
||||
final String head = Base64.encode("{\"alg\": \"none\"}");
|
||||
final String payload = Base64.encode("{\"exp\": 1642196407}");
|
||||
final String token = StrUtil.format("{}.{}.", head, payload);
|
||||
|
||||
final JWT jwt = JWTUtil.parseToken(token);
|
||||
Assertions.assertNull(jwt.getSigner());
|
||||
@@ -46,9 +46,9 @@ public class Issue4105Test {
|
||||
void verifyEmptyTest() {
|
||||
// {"alg": "none"}.{"exp": 1642196407}
|
||||
// 当定义alg为none时,校验总是成功
|
||||
String head = Base64.encode("{\"alg\": \"\"}");
|
||||
String payload = Base64.encode("{\"exp\": 1642196407}");
|
||||
String token = StrUtil.format("{}.{}.", head, payload);
|
||||
final String head = Base64.encode("{\"alg\": \"\"}");
|
||||
final String payload = Base64.encode("{\"exp\": 1642196407}");
|
||||
final String token = StrUtil.format("{}.{}.", head, payload);
|
||||
|
||||
final JWT jwt = JWTUtil.parseToken(token);
|
||||
Assertions.assertNull(jwt.getSigner());
|
||||
@@ -64,9 +64,9 @@ public class Issue4105Test {
|
||||
void verifyHs256Test() {
|
||||
// {"alg": "none"}.{"exp": 1642196407}
|
||||
// 当定义alg为none时,校验总是成功
|
||||
String head = Base64.encode("{\"alg\": \"HS256\"}");
|
||||
String payload = Base64.encode("{\"exp\": 1642196407}");
|
||||
String token = StrUtil.format("{}.{}.", head, payload);
|
||||
final String head = Base64.encode("{\"alg\": \"HS256\"}");
|
||||
final String payload = Base64.encode("{\"exp\": 1642196407}");
|
||||
final String token = StrUtil.format("{}.{}.", head, payload);
|
||||
|
||||
final JWT jwt = JWTUtil.parseToken(token);
|
||||
Assertions.assertNull(jwt.getSigner());
|
||||
|
||||
@@ -17,7 +17,7 @@ public class IssueID0HP2Test {
|
||||
final JSONObject json = JSONUtil.ofObj(JSONConfig.of().setDateFormat("yyyy/MM/dd"))
|
||||
.putValue("date", DateUtil.parse("2025-10-03"));
|
||||
|
||||
String xml = JSONUtil.toXmlStr(json);
|
||||
final String xml = JSONUtil.toXmlStr(json);
|
||||
Assertions.assertEquals("<date>2025/10/03</date>", xml);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user