mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add Deserializer
This commit is contained in:
@@ -24,10 +24,10 @@ import java.lang.reflect.Type;
|
||||
* 在Bean注入过程中,Bean获得字段名,通过外部方式根据这个字段名查找相应的字段值,然后注入Bean<br>
|
||||
*
|
||||
* @author Looly
|
||||
* @param <T> KEY类型,一般情况下为 {@link String}
|
||||
* @param <K> KEY类型,一般情况下为 {@link String}
|
||||
*
|
||||
*/
|
||||
public interface ValueProvider<T>{
|
||||
public interface ValueProvider<K>{
|
||||
|
||||
/**
|
||||
* 获取值<br>
|
||||
@@ -37,7 +37,7 @@ public interface ValueProvider<T>{
|
||||
* @param valueType 被注入的值的类型
|
||||
* @return 对应参数名的值
|
||||
*/
|
||||
Object value(T key, Type valueType);
|
||||
Object value(K key, Type valueType);
|
||||
|
||||
/**
|
||||
* 是否包含指定KEY,如果不包含则忽略注入<br>
|
||||
@@ -46,5 +46,5 @@ public interface ValueProvider<T>{
|
||||
* @param key Bean对象中参数名
|
||||
* @return 是否包含指定KEY
|
||||
*/
|
||||
boolean containsKey(T key);
|
||||
boolean containsKey(K key);
|
||||
}
|
||||
|
@@ -740,11 +740,17 @@ public class CollUtil {
|
||||
*
|
||||
* @param <T> 集合元素类型,rawtype 如 ArrayList.class, EnumSet.class ...
|
||||
* @param collectionType 集合类型
|
||||
* @param elementType 集合元素类,只用于EnumSet创建,如果创建EnumSet,则此参数必须非空
|
||||
* @return 集合类型对应的实例
|
||||
* @since 3.0.8
|
||||
*/
|
||||
public static <T> Collection<T> create(final Class<?> collectionType) {
|
||||
return create(collectionType, null);
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T> Collection<T> create(final Class<?> collectionType, final Class<T> elementType) {
|
||||
if (collectionType.isAssignableFrom(EnumSet.class)) {
|
||||
return (Collection<T>) EnumSet.noneOf((Class<Enum>) Assert.notNull(elementType));
|
||||
}
|
||||
|
||||
return create(collectionType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -752,12 +758,11 @@ public class CollUtil {
|
||||
*
|
||||
* @param <T> 集合元素类型,rawtype 如 ArrayList.class, EnumSet.class ...
|
||||
* @param collectionType 集合类型
|
||||
* @param elementType 集合元素类,只用于EnumSet创建,如果创建EnumSet,则此参数必须非空
|
||||
* @return 集合类型对应的实例
|
||||
* @since 3.0.8
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T> Collection<T> create(final Class<?> collectionType, final Class<T> elementType) {
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public static <T> Collection<T> create(final Class<?> collectionType) {
|
||||
final Collection<T> list;
|
||||
if (collectionType.isAssignableFrom(AbstractCollection.class)) {
|
||||
// 抽象集合默认使用ArrayList
|
||||
@@ -777,8 +782,6 @@ public class CollUtil {
|
||||
}
|
||||
return CompareUtil.compare(o1.toString(), o2.toString());
|
||||
});
|
||||
} else if (collectionType.isAssignableFrom(EnumSet.class)) {
|
||||
list = (Collection<T>) EnumSet.noneOf((Class<Enum>) Assert.notNull(elementType));
|
||||
}
|
||||
|
||||
// List
|
||||
|
Reference in New Issue
Block a user