public class DataUtil extends Object
| 构造器和说明 |
|---|
DataUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> List<T> |
arr2List(T[] t)
数组转集合
|
static <S,T> T |
copy(S source,
T target)
复制对象属性,包含源对象中值为null的属性
|
static <S,T> T |
copyIgnoreNull(S source,
T target)
复制对象属性,,跳过源对象中值为null的属性,如果src为null,直接返回target对象
|
static <S,T> List<T> |
copyList(Collection<S> source,
Function<S,T> mapper)
复制列表
|
static <S,T> List<T> |
copyList(Collection<S> source,
Function<S,T> mapper,
boolean ignoreNull)
复制列表
|
static <T> List<T> |
distinctList(List<T> list)
集合去重
|
static <T> List<T> |
randomList(List<T> list,
int length)
在一个集合中随机取出N个对象
|
@Nonnull public static <S,T> List<T> copyList(@Nullable Collection<S> source, @Nonnull Function<S,T> mapper)
S - 源类型T - 目标类型source - 源集合mapper - 复制实现@Nonnull public static <S,T> List<T> copyList(@Nullable Collection<S> source, @Nonnull Function<S,T> mapper, boolean ignoreNull)
S - 源类型T - 目标类型source - 源集合mapper - 复制实现ignoreNull - 是否跳过空条目@Nonnull public static <S,T> T copy(@Nullable S source, @Nonnull T target)
S - 源类型T - 目标类型source - 源对象target - 目标对象@Nonnull public static <S,T> T copyIgnoreNull(@Nullable S source, @Nonnull T target)
S - 源类型T - 目标类型source - 源对象target - 目标对象@Nonnull public static <T> List<T> arr2List(@Nonnull T[] t)
T - 类t - 数组@Nonnull public static <T> List<T> randomList(@Nonnull List<T> list, int length)
T - 对象类list - 集合length - 随机取出数量Copyright © 2018. All rights reserved.