fix get null bug

This commit is contained in:
Looly 2021-09-27 11:56:33 +08:00
parent 6db6d70293
commit 1ab9b6b3e9
4 changed files with 19 additions and 30 deletions

View File

@ -3,7 +3,7 @@
-------------------------------------------------------------------------------------------------------------
# 5.7.14 (2021-09-25)
# 5.7.14 (2021-09-27)
### 🐣新特性
* 【extra 】 修复HttpCookie设置cookies的方法不符合RFC6265规范问题issue#I4B70D@Gitee
@ -16,6 +16,7 @@
### 🐞Bug修复
* 【http 】 修复HttpCookie设置cookies的方法不符合RFC6265规范问题pr#418@Gitee
* 【http 】 修复Extractor中filter无效问题
* 【json 】 修复JSONGetter.getJSONArray判断null的问题issue#I4C15H@Gitee
-------------------------------------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@ package cn.hutool.core.codec;
import cn.hutool.core.lang.Assert;
/**
* BCD码Binary-Coded Decimal亦称二进码十进数或二-十进制代码<br>
* BCD码Binary-Coded Decimal亦称二进码十进数或二-十进制代码<br>
* BCD码这种编码形式利用了四个位元来储存一个十进制的数码使二进制和十进制之间的转换得以快捷的进行<br>
* see http://cuisuqiang.iteye.com/blog/1429956
* @author Looly

View File

@ -1,9 +1,16 @@
package cn.hutool.core.collection;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.junit.Assert;
import org.junit.Test;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* {@link IterUtil} 单元测试
@ -83,29 +90,10 @@ public class IterUtilTest {
Assert.assertEquals(expectedMap, testMap);
}
@Data
@AllArgsConstructor
public static class Car {
private String carNumber;
private String carName;
public Car(String carNumber, String carName) {
this.carNumber = carNumber;
this.carName = carName;
}
public String getCarNumber() {
return carNumber;
}
public void setCarNumber(String carNumber) {
this.carNumber = carNumber;
}
public String getCarName() {
return carName;
}
public void setCarName(String carName) {
this.carName = carName;
}
}
}

View File

@ -34,7 +34,7 @@ public interface JSONGetter<K> extends OptNullBasicTypeFromObjectGetter<K> {
* @return true 无此key或值为{@code null}{@link JSONNull#NULL}返回{@code false}其它返回{@code true}
*/
default boolean isNull(K key) {
return JSONNull.NULL.equals(this.getObj(key));
return JSONUtil.isNull(this.getObj(key));
}
/**
@ -69,7 +69,7 @@ public interface JSONGetter<K> extends OptNullBasicTypeFromObjectGetter<K> {
*/
default JSONArray getJSONArray(K key) {
final Object object = this.getObj(key);
if (null == object) {
if (JSONUtil.isNull(object)) {
return null;
}
@ -88,7 +88,7 @@ public interface JSONGetter<K> extends OptNullBasicTypeFromObjectGetter<K> {
*/
default JSONObject getJSONObject(K key) {
final Object object = this.getObj(key);
if (null == object) {
if (JSONUtil.isNull(object)) {
return null;
}
@ -117,7 +117,7 @@ public interface JSONGetter<K> extends OptNullBasicTypeFromObjectGetter<K> {
default Date getDate(K key, Date defaultValue) {
// 默认转换
final Object obj = getObj(key);
if (null == obj) {
if (JSONUtil.isNull(obj)) {
return defaultValue;
}
if (obj instanceof Date) {
@ -151,7 +151,7 @@ public interface JSONGetter<K> extends OptNullBasicTypeFromObjectGetter<K> {
default LocalDateTime getLocalDateTime(K key, LocalDateTime defaultValue) {
// 默认转换
final Object obj = getObj(key);
if (null == obj) {
if (JSONUtil.isNull(obj)) {
return defaultValue;
}
if (obj instanceof LocalDateTime) {
@ -202,7 +202,7 @@ public interface JSONGetter<K> extends OptNullBasicTypeFromObjectGetter<K> {
*/
default <T> T get(K key, Class<T> type, boolean ignoreError) throws ConvertException {
final Object value = this.getObj(key);
if (null == value) {
if (JSONUtil.isNull(value)) {
return null;
}
return JSONConverter.jsonConvert(type, value, ignoreError);