mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
Convert change to ConvertUtil
This commit is contained in:
@@ -19,7 +19,7 @@ package org.dromara.hutool.json;
|
||||
import org.dromara.hutool.core.array.ArrayUtil;
|
||||
import org.dromara.hutool.core.bean.copier.CopyOptions;
|
||||
import org.dromara.hutool.core.codec.binary.HexUtil;
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.convert.ConvertUtil;
|
||||
import org.dromara.hutool.core.io.IORuntimeException;
|
||||
import org.dromara.hutool.core.lang.mutable.MutableEntry;
|
||||
import org.dromara.hutool.core.map.CaseInsensitiveLinkedMap;
|
||||
@@ -148,7 +148,7 @@ public final class InternalJSONUtil {
|
||||
* @param predicate 属性过滤器,{@link Predicate#test(Object)}为{@code true}保留
|
||||
*/
|
||||
public static void propertyPut(final JSONObject jsonObject, final Object key, final Object value, final Predicate<MutableEntry<String, Object>> predicate) {
|
||||
final String[] path = SplitUtil.splitToArray(Convert.toStr(key), StrUtil.DOT);
|
||||
final String[] path = SplitUtil.splitToArray(ConvertUtil.toStr(key), StrUtil.DOT);
|
||||
final int last = path.length - 1;
|
||||
JSONObject target = jsonObject;
|
||||
for (int i = 0; i < last; i += 1) {
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package org.dromara.hutool.json;
|
||||
|
||||
import org.dromara.hutool.core.collection.CollUtil;
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.convert.ConvertUtil;
|
||||
import org.dromara.hutool.core.convert.impl.ArrayConverter;
|
||||
import org.dromara.hutool.core.lang.Validator;
|
||||
import org.dromara.hutool.core.lang.mutable.Mutable;
|
||||
@@ -520,7 +520,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
* @since 3.0.8
|
||||
*/
|
||||
public <T> List<T> toList(final Class<T> elementType) {
|
||||
return Convert.toList(elementType, this);
|
||||
return ConvertUtil.toList(elementType, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.dromara.hutool.json;
|
||||
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.convert.ConvertUtil;
|
||||
import org.dromara.hutool.core.io.IORuntimeException;
|
||||
import org.dromara.hutool.core.io.file.FileUtil;
|
||||
import org.dromara.hutool.core.lang.Assert;
|
||||
@@ -397,7 +397,7 @@ public class JSONUtil {
|
||||
}
|
||||
|
||||
//issue#I7CW27,其他类型使用默认转换
|
||||
return Convert.convert(type, json);
|
||||
return ConvertUtil.convert(type, json);
|
||||
}
|
||||
// -------------------------------------------------------------------- toBean end
|
||||
|
||||
|
@@ -20,7 +20,7 @@ import org.dromara.hutool.core.array.ArrayUtil;
|
||||
import org.dromara.hutool.core.bean.BeanUtil;
|
||||
import org.dromara.hutool.core.bean.RecordUtil;
|
||||
import org.dromara.hutool.core.bean.copier.BeanCopier;
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.convert.ConvertUtil;
|
||||
import org.dromara.hutool.core.convert.ConvertException;
|
||||
import org.dromara.hutool.core.convert.Converter;
|
||||
import org.dromara.hutool.core.convert.RegisterConverter;
|
||||
@@ -121,7 +121,7 @@ public class JSONConverter implements Converter, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
return Convert.convertWithCheck(targetType, value, null, config.isIgnoreError());
|
||||
return ConvertUtil.convertWithCheck(targetType, value, null, config.isIgnoreError());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,7 +19,7 @@ package org.dromara.hutool.json.mapper;
|
||||
import org.dromara.hutool.core.bean.BeanUtil;
|
||||
import org.dromara.hutool.core.bean.RecordUtil;
|
||||
import org.dromara.hutool.core.bean.copier.CopyOptions;
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.convert.ConvertUtil;
|
||||
import org.dromara.hutool.core.io.IoUtil;
|
||||
import org.dromara.hutool.core.lang.mutable.MutableEntry;
|
||||
import org.dromara.hutool.core.reflect.method.MethodUtil;
|
||||
@@ -114,11 +114,11 @@ public class JSONObjectMapper {
|
||||
} else if (source instanceof Map) {
|
||||
// Map
|
||||
for (final Map.Entry<?, ?> e : ((Map<?, ?>) source).entrySet()) {
|
||||
jsonObject.set(Convert.toStr(e.getKey()), e.getValue(), predicate, false);
|
||||
jsonObject.set(ConvertUtil.toStr(e.getKey()), e.getValue(), predicate, false);
|
||||
}
|
||||
} else if (source instanceof Map.Entry) {
|
||||
final Map.Entry entry = (Map.Entry) source;
|
||||
jsonObject.set(Convert.toStr(entry.getKey()), entry.getValue(), predicate, false);
|
||||
jsonObject.set(ConvertUtil.toStr(entry.getKey()), entry.getValue(), predicate, false);
|
||||
} else if (source instanceof CharSequence) {
|
||||
// 可能为JSON字符串
|
||||
mapFromStr((CharSequence) source, jsonObject);
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.dromara.hutool.json.serialize;
|
||||
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.convert.ConvertUtil;
|
||||
import org.dromara.hutool.core.date.DateUtil;
|
||||
import org.dromara.hutool.core.date.TemporalAccessorUtil;
|
||||
import org.dromara.hutool.core.date.format.GlobalCustomFormat;
|
||||
@@ -86,7 +86,7 @@ public class DateJSONString implements JSONStringer {
|
||||
if (dateObj instanceof TemporalAccessor) {
|
||||
dateStr = TemporalAccessorUtil.format((TemporalAccessor) dateObj, format);
|
||||
} else {
|
||||
dateStr = DateUtil.format(Convert.toDate(dateObj), format);
|
||||
dateStr = DateUtil.format(ConvertUtil.toDate(dateObj), format);
|
||||
}
|
||||
|
||||
if (GlobalCustomFormat.FORMAT_SECONDS.equals(format)
|
||||
|
@@ -13,7 +13,7 @@
|
||||
package org.dromara.hutool.json;
|
||||
|
||||
import org.dromara.hutool.core.bean.BeanUtil;
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.convert.ConvertUtil;
|
||||
import org.dromara.hutool.core.reflect.TypeReference;
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -31,7 +31,7 @@ public class Issue1101Test {
|
||||
public void treeMapConvertTest(){
|
||||
final String json = "[{\"nodeName\":\"admin\",\"treeNodeId\":\"00010001_52c95b83-2083-4138-99fb-e6e21f0c1277\",\"sort\":0,\"type\":10,\"parentId\":\"00010001\",\"children\":[],\"id\":\"52c95b83-2083-4138-99fb-e6e21f0c1277\",\"status\":true},{\"nodeName\":\"test\",\"treeNodeId\":\"00010001_97054a82-f8ff-46a1-b76c-cbacf6d18045\",\"sort\":0,\"type\":10,\"parentId\":\"00010001\",\"children\":[],\"id\":\"97054a82-f8ff-46a1-b76c-cbacf6d18045\",\"status\":true}]";
|
||||
final JSONArray objects = JSONUtil.parseArray(json);
|
||||
final TreeSet<TreeNodeDto> convert = Convert.convert(new TypeReference<TreeSet<TreeNodeDto>>() {
|
||||
final TreeSet<TreeNodeDto> convert = ConvertUtil.convert(new TypeReference<TreeSet<TreeNodeDto>>() {
|
||||
}, objects);
|
||||
Assertions.assertEquals(2, convert.size());
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
package org.dromara.hutool.json;
|
||||
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.convert.ConvertUtil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -82,7 +82,7 @@ public class IssueI49VZBTest {
|
||||
|
||||
@Test
|
||||
public void enumConvertTest(){
|
||||
final NBCloudKeyType type = Convert.toEnum(NBCloudKeyType.class, "snapKey");
|
||||
final NBCloudKeyType type = ConvertUtil.toEnum(NBCloudKeyType.class, "snapKey");
|
||||
Assertions.assertEquals(NBCloudKeyType.snapKey, type);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user