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

@@ -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);