mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
add SetUtil
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.annotation;
|
package cn.hutool.core.annotation;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.map.TableMap;
|
import cn.hutool.core.map.TableMap;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -42,7 +42,7 @@ public class CombinationAnnotationElement implements AnnotatedElement, Serializa
|
|||||||
/**
|
/**
|
||||||
* 元注解
|
* 元注解
|
||||||
*/
|
*/
|
||||||
private static final Set<Class<? extends Annotation>> META_ANNOTATIONS = CollUtil.newHashSet(Target.class, //
|
private static final Set<Class<? extends Annotation>> META_ANNOTATIONS = SetUtil.newHashSet(Target.class, //
|
||||||
Retention.class, //
|
Retention.class, //
|
||||||
Inherited.class, //
|
Inherited.class, //
|
||||||
Documented.class, //
|
Documented.class, //
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.copier.BeanCopier;
|
|||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import cn.hutool.core.bean.copier.ValueProvider;
|
import cn.hutool.core.bean.copier.ValueProvider;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.func.Editor;
|
import cn.hutool.core.lang.func.Editor;
|
||||||
import cn.hutool.core.map.CaseInsensitiveMap;
|
import cn.hutool.core.map.CaseInsensitiveMap;
|
||||||
@@ -574,7 +575,7 @@ public class BeanUtil {
|
|||||||
public static Map<String, Object> beanToMap(final Object bean, final String... properties) {
|
public static Map<String, Object> beanToMap(final Object bean, final String... properties) {
|
||||||
Editor<String> keyEditor = null;
|
Editor<String> keyEditor = null;
|
||||||
if(ArrayUtil.isNotEmpty(properties)){
|
if(ArrayUtil.isNotEmpty(properties)){
|
||||||
final Set<String> propertiesSet = CollUtil.set(false, properties);
|
final Set<String> propertiesSet = SetUtil.set(false, properties);
|
||||||
keyEditor = property -> propertiesSet.contains(property) ? property : null;
|
keyEditor = property -> propertiesSet.contains(property) ? property : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ import java.util.TreeMap;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -122,7 +121,7 @@ public class CollUtil {
|
|||||||
final ArrayList<T> list = new ArrayList<>(Math.max(coll1.size(), coll2.size()));
|
final ArrayList<T> list = new ArrayList<>(Math.max(coll1.size(), coll2.size()));
|
||||||
final Map<T, Integer> map1 = countMap(coll1);
|
final Map<T, Integer> map1 = countMap(coll1);
|
||||||
final Map<T, Integer> map2 = countMap(coll2);
|
final Map<T, Integer> map2 = countMap(coll2);
|
||||||
final Set<T> elts = newHashSet(coll2);
|
final Set<T> elts = SetUtil.newHashSet(coll2);
|
||||||
elts.addAll(coll1);
|
elts.addAll(coll1);
|
||||||
int m;
|
int m;
|
||||||
for (final T t : elts) {
|
for (final T t : elts) {
|
||||||
@@ -239,7 +238,7 @@ public class CollUtil {
|
|||||||
final ArrayList<T> list = new ArrayList<>(Math.min(coll1.size(), coll2.size()));
|
final ArrayList<T> list = new ArrayList<>(Math.min(coll1.size(), coll2.size()));
|
||||||
final Map<T, Integer> map1 = countMap(coll1);
|
final Map<T, Integer> map1 = countMap(coll1);
|
||||||
final Map<T, Integer> map2 = countMap(coll2);
|
final Map<T, Integer> map2 = countMap(coll2);
|
||||||
final Set<T> elts = newHashSet(coll2);
|
final Set<T> elts = SetUtil.newHashSet(coll2);
|
||||||
int m;
|
int m;
|
||||||
for (final T t : elts) {
|
for (final T t : elts) {
|
||||||
m = Math.min(Convert.toInt(map1.get(t), 0), Convert.toInt(map2.get(t), 0));
|
m = Math.min(Convert.toInt(map1.get(t), 0), Convert.toInt(map2.get(t), 0));
|
||||||
@@ -348,7 +347,7 @@ public class CollUtil {
|
|||||||
final List<T> result = new ArrayList<>();
|
final List<T> result = new ArrayList<>();
|
||||||
final Map<T, Integer> map1 = countMap(coll1);
|
final Map<T, Integer> map1 = countMap(coll1);
|
||||||
final Map<T, Integer> map2 = countMap(coll2);
|
final Map<T, Integer> map2 = countMap(coll2);
|
||||||
final Set<T> elts = newHashSet(coll2);
|
final Set<T> elts = SetUtil.newHashSet(coll2);
|
||||||
elts.addAll(coll1);
|
elts.addAll(coll1);
|
||||||
int m;
|
int m;
|
||||||
for (final T t : elts) {
|
for (final T t : elts) {
|
||||||
@@ -654,300 +653,6 @@ public class CollUtil {
|
|||||||
return currentAlaDatas;
|
return currentAlaDatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------- new HashSet
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个HashSet
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param ts 元素数组
|
|
||||||
* @return HashSet对象
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
public static <T> HashSet<T> newHashSet(final T... ts) {
|
|
||||||
return set(false, ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个LinkedHashSet
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param ts 元素数组
|
|
||||||
* @return HashSet对象
|
|
||||||
* @since 4.1.10
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
public static <T> LinkedHashSet<T> newLinkedHashSet(final T... ts) {
|
|
||||||
return (LinkedHashSet<T>) set(true, ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个HashSet
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isSorted 是否有序,有序返回 {@link LinkedHashSet},否则返回 {@link HashSet}
|
|
||||||
* @param ts 元素数组
|
|
||||||
* @return HashSet对象
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
public static <T> HashSet<T> set(final boolean isSorted, final T... ts) {
|
|
||||||
if (null == ts) {
|
|
||||||
return isSorted ? new LinkedHashSet<>() : new HashSet<>();
|
|
||||||
}
|
|
||||||
final int initialCapacity = Math.max((int) (ts.length / .75f) + 1, 16);
|
|
||||||
final HashSet<T> set = isSorted ? new LinkedHashSet<>(initialCapacity) : new HashSet<>(initialCapacity);
|
|
||||||
Collections.addAll(set, ts);
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个HashSet
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param collection 集合
|
|
||||||
* @return HashSet对象
|
|
||||||
*/
|
|
||||||
public static <T> HashSet<T> newHashSet(final Collection<T> collection) {
|
|
||||||
return newHashSet(false, collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个HashSet
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isSorted 是否有序,有序返回 {@link LinkedHashSet},否则返回{@link HashSet}
|
|
||||||
* @param collection 集合,用于初始化Set
|
|
||||||
* @return HashSet对象
|
|
||||||
*/
|
|
||||||
public static <T> HashSet<T> newHashSet(final boolean isSorted, final Collection<T> collection) {
|
|
||||||
return isSorted ? new LinkedHashSet<>(collection) : new HashSet<>(collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个HashSet
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isSorted 是否有序,有序返回 {@link LinkedHashSet},否则返回{@link HashSet}
|
|
||||||
* @param iter {@link Iterator}
|
|
||||||
* @return HashSet对象
|
|
||||||
* @since 3.0.8
|
|
||||||
*/
|
|
||||||
public static <T> HashSet<T> newHashSet(final boolean isSorted, final Iterator<T> iter) {
|
|
||||||
if (null == iter) {
|
|
||||||
return set(isSorted, (T[]) null);
|
|
||||||
}
|
|
||||||
final HashSet<T> set = isSorted ? new LinkedHashSet<>() : new HashSet<>();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
set.add(iter.next());
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个HashSet
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isSorted 是否有序,有序返回 {@link LinkedHashSet},否则返回{@link HashSet}
|
|
||||||
* @param enumeration {@link Enumeration}
|
|
||||||
* @return HashSet对象
|
|
||||||
* @since 3.0.8
|
|
||||||
*/
|
|
||||||
public static <T> HashSet<T> newHashSet(final boolean isSorted, final Enumeration<T> enumeration) {
|
|
||||||
if (null == enumeration) {
|
|
||||||
return set(isSorted, (T[]) null);
|
|
||||||
}
|
|
||||||
final HashSet<T> set = isSorted ? new LinkedHashSet<>() : new HashSet<>();
|
|
||||||
while (enumeration.hasMoreElements()) {
|
|
||||||
set.add(enumeration.nextElement());
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------- List
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个空List
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isLinked 是否新建LinkedList
|
|
||||||
* @return List对象
|
|
||||||
* @since 4.1.2
|
|
||||||
*/
|
|
||||||
public static <T> List<T> list(final boolean isLinked) {
|
|
||||||
return ListUtil.list(isLinked);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个List
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isLinked 是否新建LinkedList
|
|
||||||
* @param values 数组
|
|
||||||
* @return List对象
|
|
||||||
* @since 4.1.2
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
public static <T> List<T> list(final boolean isLinked, final T... values) {
|
|
||||||
return ListUtil.list(isLinked, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个List
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isLinked 是否新建LinkedList
|
|
||||||
* @param collection 集合
|
|
||||||
* @return List对象
|
|
||||||
* @since 4.1.2
|
|
||||||
*/
|
|
||||||
public static <T> List<T> list(final boolean isLinked, final Collection<T> collection) {
|
|
||||||
return ListUtil.list(isLinked, collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个List<br>
|
|
||||||
* 提供的参数为null时返回空{@link ArrayList}
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isLinked 是否新建LinkedList
|
|
||||||
* @param iterable {@link Iterable}
|
|
||||||
* @return List对象
|
|
||||||
* @since 4.1.2
|
|
||||||
*/
|
|
||||||
public static <T> List<T> list(final boolean isLinked, final Iterable<T> iterable) {
|
|
||||||
return ListUtil.list(isLinked, iterable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个ArrayList<br>
|
|
||||||
* 提供的参数为null时返回空{@link ArrayList}
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isLinked 是否新建LinkedList
|
|
||||||
* @param iter {@link Iterator}
|
|
||||||
* @return ArrayList对象
|
|
||||||
* @since 4.1.2
|
|
||||||
*/
|
|
||||||
public static <T> List<T> list(final boolean isLinked, final Iterator<T> iter) {
|
|
||||||
return ListUtil.list(isLinked, iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个List<br>
|
|
||||||
* 提供的参数为null时返回空{@link ArrayList}
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param isLinked 是否新建LinkedList
|
|
||||||
* @param enumeration {@link Enumeration}
|
|
||||||
* @return ArrayList对象
|
|
||||||
* @since 3.0.8
|
|
||||||
*/
|
|
||||||
public static <T> List<T> list(final boolean isLinked, final Enumeration<T> enumeration) {
|
|
||||||
return ListUtil.list(isLinked, enumeration);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个ArrayList
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param values 数组
|
|
||||||
* @return ArrayList对象
|
|
||||||
* @see #toList(Object[])
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
public static <T> ArrayList<T> newArrayList(final T... values) {
|
|
||||||
return ListUtil.toList(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数组转为ArrayList
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param values 数组
|
|
||||||
* @return ArrayList对象
|
|
||||||
* @since 4.0.11
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
public static <T> ArrayList<T> toList(final T... values) {
|
|
||||||
return ListUtil.toList(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个ArrayList
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param collection 集合
|
|
||||||
* @return ArrayList对象
|
|
||||||
*/
|
|
||||||
public static <T> ArrayList<T> newArrayList(final Collection<T> collection) {
|
|
||||||
return ListUtil.toList(collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个ArrayList<br>
|
|
||||||
* 提供的参数为null时返回空{@link ArrayList}
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param iterable {@link Iterable}
|
|
||||||
* @return ArrayList对象
|
|
||||||
* @since 3.1.0
|
|
||||||
*/
|
|
||||||
public static <T> ArrayList<T> newArrayList(final Iterable<T> iterable) {
|
|
||||||
return ListUtil.toList(iterable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个ArrayList<br>
|
|
||||||
* 提供的参数为null时返回空{@link ArrayList}
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param iterator {@link Iterator}
|
|
||||||
* @return ArrayList对象
|
|
||||||
* @since 3.0.8
|
|
||||||
*/
|
|
||||||
public static <T> ArrayList<T> newArrayList(final Iterator<T> iterator) {
|
|
||||||
return ListUtil.toList(iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个ArrayList<br>
|
|
||||||
* 提供的参数为null时返回空{@link ArrayList}
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param enumeration {@link Enumeration}
|
|
||||||
* @return ArrayList对象
|
|
||||||
* @since 3.0.8
|
|
||||||
*/
|
|
||||||
public static <T> ArrayList<T> newArrayList(final Enumeration<T> enumeration) {
|
|
||||||
return ListUtil.toList(enumeration);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------new LinkedList
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建LinkedList
|
|
||||||
*
|
|
||||||
* @param values 数组
|
|
||||||
* @param <T> 类型
|
|
||||||
* @return LinkedList
|
|
||||||
* @since 4.1.2
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
public static <T> LinkedList<T> newLinkedList(final T... values) {
|
|
||||||
return ListUtil.toLinkedList(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建一个CopyOnWriteArrayList
|
|
||||||
*
|
|
||||||
* @param <T> 集合元素类型
|
|
||||||
* @param collection 集合
|
|
||||||
* @return {@link CopyOnWriteArrayList}
|
|
||||||
*/
|
|
||||||
public static <T> CopyOnWriteArrayList<T> newCopyOnWriteArrayList(final Collection<T> collection) {
|
|
||||||
return ListUtil.toCopyOnWriteArrayList(collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新建{@link BlockingQueue}<br>
|
* 新建{@link BlockingQueue}<br>
|
||||||
* 在队列为空时,获取元素的线程会等待队列变为非空。当队列满时,存储元素的线程会等待队列可用。
|
* 在队列为空时,获取元素的线程会等待队列变为非空。当队列满时,存储元素的线程会等待队列可用。
|
||||||
@@ -1222,7 +927,7 @@ public class CollUtil {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T extends Collection<E>, E> T removeAny(final T collection, final E... elesRemoved) {
|
public static <T extends Collection<E>, E> T removeAny(final T collection, final E... elesRemoved) {
|
||||||
collection.removeAll(newHashSet(elesRemoved));
|
collection.removeAll(SetUtil.newHashSet(elesRemoved));
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1927,7 +1632,7 @@ public class CollUtil {
|
|||||||
* @since 3.0.9
|
* @since 3.0.9
|
||||||
*/
|
*/
|
||||||
public static <E> Collection<E> toCollection(final Iterable<E> iterable) {
|
public static <E> Collection<E> toCollection(final Iterable<E> iterable) {
|
||||||
return (iterable instanceof Collection) ? (Collection<E>) iterable : newArrayList(iterable.iterator());
|
return (iterable instanceof Collection) ? (Collection<E>) iterable : ListUtil.toList(iterable.iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2082,7 +1787,7 @@ public class CollUtil {
|
|||||||
iter = StrUtil.splitTrim(ArrayStr, CharUtil.COMMA).iterator();
|
iter = StrUtil.splitTrim(ArrayStr, CharUtil.COMMA).iterator();
|
||||||
} else {
|
} else {
|
||||||
// 其它类型按照单一元素处理
|
// 其它类型按照单一元素处理
|
||||||
iter = CollUtil.newArrayList(value).iterator();
|
iter = ListUtil.toList(value).iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ConverterRegistry convert = ConverterRegistry.getInstance();
|
final ConverterRegistry convert = ConverterRegistry.getInstance();
|
||||||
@@ -2522,14 +2227,14 @@ public class CollUtil {
|
|||||||
// ------------------------------------------------------------------------------------------------- forEach
|
// ------------------------------------------------------------------------------------------------- forEach
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 循环遍历 {@link Iterable},使用{@link Consumer} 接受遍历的每条数据,并针对每条数据做处理
|
* 循环遍历 {@link Iterable},使用{@link IndexedConsumer} 接受遍历的每条数据,并针对每条数据做处理
|
||||||
*
|
*
|
||||||
* @param <T> 集合元素类型
|
* @param <T> 集合元素类型
|
||||||
* @param iterable {@link Iterable}
|
* @param iterable {@link Iterable}
|
||||||
* @param consumer {@link Consumer} 遍历的每条数据处理器
|
* @param consumer {@link IndexedConsumer} 遍历的每条数据处理器
|
||||||
* @since 5.4.7
|
* @since 5.4.7
|
||||||
*/
|
*/
|
||||||
public static <T> void forEach(final Iterable<T> iterable, final Consumer<T> consumer) {
|
public static <T> void forEach(final Iterable<T> iterable, final IndexedConsumer<T> consumer) {
|
||||||
if (iterable == null) {
|
if (iterable == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2537,13 +2242,13 @@ public class CollUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 循环遍历 {@link Iterator},使用{@link Consumer} 接受遍历的每条数据,并针对每条数据做处理
|
* 循环遍历 {@link Iterator},使用{@link IndexedConsumer} 接受遍历的每条数据,并针对每条数据做处理
|
||||||
*
|
*
|
||||||
* @param <T> 集合元素类型
|
* @param <T> 集合元素类型
|
||||||
* @param iterator {@link Iterator}
|
* @param iterator {@link Iterator}
|
||||||
* @param consumer {@link Consumer} 遍历的每条数据处理器
|
* @param consumer {@link IndexedConsumer} 遍历的每条数据处理器
|
||||||
*/
|
*/
|
||||||
public static <T> void forEach(final Iterator<T> iterator, final Consumer<T> consumer) {
|
public static <T> void forEach(final Iterator<T> iterator, final IndexedConsumer<T> consumer) {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2555,13 +2260,13 @@ public class CollUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 循环遍历 {@link Enumeration},使用{@link Consumer} 接受遍历的每条数据,并针对每条数据做处理
|
* 循环遍历 {@link Enumeration},使用{@link IndexedConsumer} 接受遍历的每条数据,并针对每条数据做处理
|
||||||
*
|
*
|
||||||
* @param <T> 集合元素类型
|
* @param <T> 集合元素类型
|
||||||
* @param enumeration {@link Enumeration}
|
* @param enumeration {@link Enumeration}
|
||||||
* @param consumer {@link Consumer} 遍历的每条数据处理器
|
* @param consumer {@link IndexedConsumer} 遍历的每条数据处理器
|
||||||
*/
|
*/
|
||||||
public static <T> void forEach(final Enumeration<T> enumeration, final Consumer<T> consumer) {
|
public static <T> void forEach(final Enumeration<T> enumeration, final IndexedConsumer<T> consumer) {
|
||||||
if (enumeration == null) {
|
if (enumeration == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2573,15 +2278,15 @@ public class CollUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 循环遍历Map,使用{@link KVConsumer} 接受遍历的每条数据,并针对每条数据做处理<br>
|
* 循环遍历Map,使用{@link IndexedKVConsumer} 接受遍历的每条数据,并针对每条数据做处理<br>
|
||||||
* 和JDK8中的map.forEach不同的是,此方法支持index
|
* 和JDK8中的map.forEach不同的是,此方法支持index
|
||||||
*
|
*
|
||||||
* @param <K> Key类型
|
* @param <K> Key类型
|
||||||
* @param <V> Value类型
|
* @param <V> Value类型
|
||||||
* @param map {@link Map}
|
* @param map {@link Map}
|
||||||
* @param kvConsumer {@link KVConsumer} 遍历的每条数据处理器
|
* @param kvConsumer {@link IndexedKVConsumer} 遍历的每条数据处理器
|
||||||
*/
|
*/
|
||||||
public static <K, V> void forEach(final Map<K, V> map, final KVConsumer<K, V> kvConsumer) {
|
public static <K, V> void forEach(final Map<K, V> map, final IndexedKVConsumer<K, V> kvConsumer) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2618,11 +2323,11 @@ public class CollUtil {
|
|||||||
while (result.size() - 1 < index) {
|
while (result.size() - 1 < index) {
|
||||||
result.add(null);
|
result.add(null);
|
||||||
}
|
}
|
||||||
result.set(index, newArrayList(t));
|
result.set(index, ListUtil.toList(t));
|
||||||
} else {
|
} else {
|
||||||
subList = result.get(index);
|
subList = result.get(index);
|
||||||
if (null == subList) {
|
if (null == subList) {
|
||||||
result.set(index, newArrayList(t));
|
result.set(index, ListUtil.toList(t));
|
||||||
} else {
|
} else {
|
||||||
subList.add(t);
|
subList.add(t);
|
||||||
}
|
}
|
||||||
@@ -2661,30 +2366,6 @@ public class CollUtil {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 反序给定List,会在原List基础上直接修改
|
|
||||||
*
|
|
||||||
* @param <T> 元素类型
|
|
||||||
* @param list 被反转的List
|
|
||||||
* @return 反转后的List
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static <T> List<T> reverse(final List<T> list) {
|
|
||||||
return ListUtil.reverse(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 反序给定List,会创建一个新的List,原List数据不变
|
|
||||||
*
|
|
||||||
* @param <T> 元素类型
|
|
||||||
* @param list 被反转的List
|
|
||||||
* @return 反转后的List
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static <T> List<T> reverseNew(final List<T> list) {
|
|
||||||
return ListUtil.reverseNew(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置或增加元素。当index小于List的长度时,替换指定位置的值,否则在尾部追加
|
* 设置或增加元素。当index小于List的长度时,替换指定位置的值,否则在尾部追加
|
||||||
*
|
*
|
||||||
@@ -2903,7 +2584,7 @@ public class CollUtil {
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Consumer<T> extends Serializable {
|
public interface IndexedConsumer<T> extends Serializable {
|
||||||
/**
|
/**
|
||||||
* 接受并处理一个参数
|
* 接受并处理一个参数
|
||||||
*
|
*
|
||||||
@@ -2921,7 +2602,7 @@ public class CollUtil {
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface KVConsumer<K, V> extends Serializable {
|
public interface IndexedKVConsumer<K, V> extends Serializable {
|
||||||
/**
|
/**
|
||||||
* 接受并处理一对参数
|
* 接受并处理一对参数
|
||||||
*
|
*
|
||||||
|
|||||||
123
hutool-core/src/main/java/cn/hutool/core/collection/SetUtil.java
Normal file
123
hutool-core/src/main/java/cn/hutool/core/collection/SetUtil.java
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
package cn.hutool.core.collection;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 集合中的{@link java.util.Set}相关方法封装
|
||||||
|
*
|
||||||
|
* @author looly
|
||||||
|
*/
|
||||||
|
public class SetUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建一个HashSet
|
||||||
|
*
|
||||||
|
* @param <T> 集合元素类型
|
||||||
|
* @param ts 元素数组
|
||||||
|
* @return HashSet对象
|
||||||
|
*/
|
||||||
|
@SafeVarargs
|
||||||
|
public static <T> HashSet<T> newHashSet(final T... ts) {
|
||||||
|
return set(false, ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建一个LinkedHashSet
|
||||||
|
*
|
||||||
|
* @param <T> 集合元素类型
|
||||||
|
* @param ts 元素数组
|
||||||
|
* @return HashSet对象
|
||||||
|
* @since 4.1.10
|
||||||
|
*/
|
||||||
|
@SafeVarargs
|
||||||
|
public static <T> LinkedHashSet<T> newLinkedHashSet(final T... ts) {
|
||||||
|
return (LinkedHashSet<T>) set(true, ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建一个HashSet
|
||||||
|
*
|
||||||
|
* @param <T> 集合元素类型
|
||||||
|
* @param isSorted 是否有序,有序返回 {@link LinkedHashSet},否则返回 {@link HashSet}
|
||||||
|
* @param ts 元素数组
|
||||||
|
* @return HashSet对象
|
||||||
|
*/
|
||||||
|
@SafeVarargs
|
||||||
|
public static <T> HashSet<T> set(final boolean isSorted, final T... ts) {
|
||||||
|
if (null == ts) {
|
||||||
|
return isSorted ? new LinkedHashSet<>() : new HashSet<>();
|
||||||
|
}
|
||||||
|
final int initialCapacity = Math.max((int) (ts.length / .75f) + 1, 16);
|
||||||
|
final HashSet<T> set = isSorted ? new LinkedHashSet<>(initialCapacity) : new HashSet<>(initialCapacity);
|
||||||
|
Collections.addAll(set, ts);
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建一个HashSet
|
||||||
|
*
|
||||||
|
* @param <T> 集合元素类型
|
||||||
|
* @param collection 集合
|
||||||
|
* @return HashSet对象
|
||||||
|
*/
|
||||||
|
public static <T> HashSet<T> newHashSet(final Collection<T> collection) {
|
||||||
|
return newHashSet(false, collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建一个HashSet
|
||||||
|
*
|
||||||
|
* @param <T> 集合元素类型
|
||||||
|
* @param isSorted 是否有序,有序返回 {@link LinkedHashSet},否则返回{@link HashSet}
|
||||||
|
* @param collection 集合,用于初始化Set
|
||||||
|
* @return HashSet对象
|
||||||
|
*/
|
||||||
|
public static <T> HashSet<T> newHashSet(final boolean isSorted, final Collection<T> collection) {
|
||||||
|
return isSorted ? new LinkedHashSet<>(collection) : new HashSet<>(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建一个HashSet
|
||||||
|
*
|
||||||
|
* @param <T> 集合元素类型
|
||||||
|
* @param isSorted 是否有序,有序返回 {@link LinkedHashSet},否则返回{@link HashSet}
|
||||||
|
* @param iter {@link Iterator}
|
||||||
|
* @return HashSet对象
|
||||||
|
* @since 3.0.8
|
||||||
|
*/
|
||||||
|
public static <T> HashSet<T> newHashSet(final boolean isSorted, final Iterator<T> iter) {
|
||||||
|
if (null == iter) {
|
||||||
|
return set(isSorted, (T[]) null);
|
||||||
|
}
|
||||||
|
final HashSet<T> set = isSorted ? new LinkedHashSet<>() : new HashSet<>();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
set.add(iter.next());
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建一个HashSet
|
||||||
|
*
|
||||||
|
* @param <T> 集合元素类型
|
||||||
|
* @param isSorted 是否有序,有序返回 {@link LinkedHashSet},否则返回{@link HashSet}
|
||||||
|
* @param enumeration {@link Enumeration}
|
||||||
|
* @return HashSet对象
|
||||||
|
* @since 3.0.8
|
||||||
|
*/
|
||||||
|
public static <T> HashSet<T> newHashSet(final boolean isSorted, final Enumeration<T> enumeration) {
|
||||||
|
if (null == enumeration) {
|
||||||
|
return set(isSorted, (T[]) null);
|
||||||
|
}
|
||||||
|
final HashSet<T> set = isSorted ? new LinkedHashSet<>() : new HashSet<>();
|
||||||
|
while (enumeration.hasMoreElements()) {
|
||||||
|
set.add(enumeration.nextElement());
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package cn.hutool.core.date;
|
package cn.hutool.core.date;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.comparator.CompareUtil;
|
import cn.hutool.core.comparator.CompareUtil;
|
||||||
import cn.hutool.core.date.format.DateParser;
|
import cn.hutool.core.date.format.DateParser;
|
||||||
import cn.hutool.core.date.format.DatePrinter;
|
import cn.hutool.core.date.format.DatePrinter;
|
||||||
import cn.hutool.core.date.format.FastDateFormat;
|
import cn.hutool.core.date.format.FastDateFormat;
|
||||||
import cn.hutool.core.date.format.GlobalCustomFormat;
|
import cn.hutool.core.date.format.GlobalCustomFormat;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.regex.PatternPool;
|
|
||||||
import cn.hutool.core.util.CharUtil;
|
|
||||||
import cn.hutool.core.math.NumberUtil;
|
import cn.hutool.core.math.NumberUtil;
|
||||||
|
import cn.hutool.core.regex.PatternPool;
|
||||||
import cn.hutool.core.regex.ReUtil;
|
import cn.hutool.core.regex.ReUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
import cn.hutool.core.util.CharUtil;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -20,7 +20,14 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.Year;
|
import java.time.Year;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.TemporalAccessor;
|
import java.time.temporal.TemporalAccessor;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -1842,8 +1849,8 @@ public class DateUtil extends CalendarUtil {
|
|||||||
* @since 5.7.21
|
* @since 5.7.21
|
||||||
*/
|
*/
|
||||||
public static List<DateTime> rangeContains(final DateRange start, final DateRange end) {
|
public static List<DateTime> rangeContains(final DateRange start, final DateRange end) {
|
||||||
final List<DateTime> startDateTimes = CollUtil.newArrayList((Iterable<DateTime>) start);
|
final List<DateTime> startDateTimes = ListUtil.toList((Iterable<DateTime>) start);
|
||||||
final List<DateTime> endDateTimes = CollUtil.newArrayList((Iterable<DateTime>) end);
|
final List<DateTime> endDateTimes = ListUtil.toList((Iterable<DateTime>) end);
|
||||||
return startDateTimes.stream().filter(endDateTimes::contains).collect(Collectors.toList());
|
return startDateTimes.stream().filter(endDateTimes::contains).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1857,8 +1864,8 @@ public class DateUtil extends CalendarUtil {
|
|||||||
* @since 5.7.21
|
* @since 5.7.21
|
||||||
*/
|
*/
|
||||||
public static List<DateTime> rangeNotContains(final DateRange start, final DateRange end) {
|
public static List<DateTime> rangeNotContains(final DateRange start, final DateRange end) {
|
||||||
final List<DateTime> startDateTimes = CollUtil.newArrayList((Iterable<DateTime>) start);
|
final List<DateTime> startDateTimes = ListUtil.toList((Iterable<DateTime>) start);
|
||||||
final List<DateTime> endDateTimes = CollUtil.newArrayList((Iterable<DateTime>) end);
|
final List<DateTime> endDateTimes = ListUtil.toList((Iterable<DateTime>) end);
|
||||||
return endDateTimes.stream().filter(item -> !startDateTimes.contains(item)).collect(Collectors.toList());
|
return endDateTimes.stream().filter(item -> !startDateTimes.contains(item)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1909,7 +1916,7 @@ public class DateUtil extends CalendarUtil {
|
|||||||
* @return {@link DateRange}
|
* @return {@link DateRange}
|
||||||
*/
|
*/
|
||||||
public static List<DateTime> rangeToList(final Date start, final Date end, final DateField unit) {
|
public static List<DateTime> rangeToList(final Date start, final Date end, final DateField unit) {
|
||||||
return CollUtil.newArrayList((Iterable<DateTime>) range(start, end, unit));
|
return ListUtil.toList((Iterable<DateTime>) range(start, end, unit));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1923,7 +1930,7 @@ public class DateUtil extends CalendarUtil {
|
|||||||
* @since 5.7.16
|
* @since 5.7.16
|
||||||
*/
|
*/
|
||||||
public static List<DateTime> rangeToList(final Date start, final Date end, final DateField unit, final int step) {
|
public static List<DateTime> rangeToList(final Date start, final Date end, final DateField unit, final int step) {
|
||||||
return CollUtil.newArrayList((Iterable<DateTime>) new DateRange(start, end, unit, step));
|
return ListUtil.toList((Iterable<DateTime>) new DateRange(start, end, unit, step));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.io.resource;
|
package cn.hutool.core.io.resource;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -32,7 +32,7 @@ public class MultiResource implements Resource, Iterable<Resource>, Iterator<Res
|
|||||||
* @param resources 资源数组
|
* @param resources 资源数组
|
||||||
*/
|
*/
|
||||||
public MultiResource(final Resource... resources) {
|
public MultiResource(final Resource... resources) {
|
||||||
this(CollUtil.newArrayList(resources));
|
this(ListUtil.toList(resources));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +44,7 @@ public class MultiResource implements Resource, Iterable<Resource>, Iterator<Res
|
|||||||
if(resources instanceof List) {
|
if(resources instanceof List) {
|
||||||
this.resources = (List<Resource>)resources;
|
this.resources = (List<Resource>)resources;
|
||||||
}else {
|
}else {
|
||||||
this.resources = CollUtil.newArrayList(resources);
|
this.resources = ListUtil.toList(resources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.io.watch.watchers;
|
package cn.hutool.core.io.watch.watchers;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.io.watch.Watcher;
|
import cn.hutool.core.io.watch.Watcher;
|
||||||
import cn.hutool.core.lang.Chain;
|
import cn.hutool.core.lang.Chain;
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ public class WatcherChain implements Watcher, Chain<Watcher, WatcherChain>{
|
|||||||
* @param watchers 观察者列表
|
* @param watchers 观察者列表
|
||||||
*/
|
*/
|
||||||
public WatcherChain(final Watcher... watchers) {
|
public WatcherChain(final Watcher... watchers) {
|
||||||
chain = CollUtil.newArrayList(watchers);
|
chain = ListUtil.toList(watchers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package cn.hutool.core.map;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanPath;
|
import cn.hutool.core.bean.BeanPath;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.lang.Pair;
|
import cn.hutool.core.lang.Pair;
|
||||||
@@ -290,7 +290,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
* @param withoutNames 不需要去除的字段名
|
* @param withoutNames 不需要去除的字段名
|
||||||
*/
|
*/
|
||||||
public <T extends Dict> void removeEqual(final T dict, final String... withoutNames) {
|
public <T extends Dict> void removeEqual(final T dict, final String... withoutNames) {
|
||||||
final HashSet<String> withoutSet = CollUtil.newHashSet(withoutNames);
|
final HashSet<String> withoutSet = SetUtil.newHashSet(withoutNames);
|
||||||
for (final Map.Entry<String, Object> entry : dict.entrySet()) {
|
for (final Map.Entry<String, Object> entry : dict.entrySet()) {
|
||||||
if (withoutSet.contains(entry.getKey())) {
|
if (withoutSet.contains(entry.getKey())) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.hutool.core.map;
|
package cn.hutool.core.map;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.func.Editor;
|
import cn.hutool.core.lang.func.Editor;
|
||||||
import cn.hutool.core.lang.func.Filter;
|
import cn.hutool.core.lang.func.Filter;
|
||||||
@@ -408,7 +409,7 @@ public class MapUtil {
|
|||||||
key = entry.getKey();
|
key = entry.getKey();
|
||||||
valueList = resultMap.get(key);
|
valueList = resultMap.get(key);
|
||||||
if (null == valueList) {
|
if (null == valueList) {
|
||||||
valueList = CollUtil.newArrayList(entry.getValue());
|
valueList = ListUtil.toList(entry.getValue());
|
||||||
resultMap.put(key, valueList);
|
resultMap.put(key, valueList);
|
||||||
} else {
|
} else {
|
||||||
valueList.add(entry.getValue());
|
valueList.add(entry.getValue());
|
||||||
@@ -463,7 +464,7 @@ public class MapUtil {
|
|||||||
List<V> vList;
|
List<V> vList;
|
||||||
int vListSize;
|
int vListSize;
|
||||||
for (final Entry<K, ? extends Iterable<V>> entry : listMap.entrySet()) {
|
for (final Entry<K, ? extends Iterable<V>> entry : listMap.entrySet()) {
|
||||||
vList = CollUtil.newArrayList(entry.getValue());
|
vList = ListUtil.toList(entry.getValue());
|
||||||
vListSize = vList.size();
|
vListSize = vList.size();
|
||||||
if (index < vListSize) {
|
if (index < vListSize) {
|
||||||
map.put(entry.getKey(), vList.get(index));
|
map.put(entry.getKey(), vList.get(index));
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ public class TableMap<K, V> implements Map<K, V>, Iterable<Map.Entry<K, V>>, Ser
|
|||||||
* @param values 值列表
|
* @param values 值列表
|
||||||
*/
|
*/
|
||||||
public TableMap(final K[] keys, final V[] values) {
|
public TableMap(final K[] keys, final V[] values) {
|
||||||
this.keys = CollUtil.toList(keys);
|
this.keys = ListUtil.toList(keys);
|
||||||
this.values = CollUtil.toList(values);
|
this.values = ListUtil.toList(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package cn.hutool.core.reflect;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.NullWrapperBean;
|
import cn.hutool.core.bean.NullWrapperBean;
|
||||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.collection.UniqueKeySet;
|
import cn.hutool.core.collection.UniqueKeySet;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
@@ -90,7 +90,7 @@ public class MethodUtil {
|
|||||||
* @return 过滤后的方法列表
|
* @return 过滤后的方法列表
|
||||||
*/
|
*/
|
||||||
public static Method[] getPublicMethods(final Class<?> clazz, final Method... excludeMethods) {
|
public static Method[] getPublicMethods(final Class<?> clazz, final Method... excludeMethods) {
|
||||||
final HashSet<Method> excludeMethodSet = CollUtil.newHashSet(excludeMethods);
|
final HashSet<Method> excludeMethodSet = SetUtil.newHashSet(excludeMethods);
|
||||||
return getPublicMethods(clazz, method -> false == excludeMethodSet.contains(method));
|
return getPublicMethods(clazz, method -> false == excludeMethodSet.contains(method));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public class MethodUtil {
|
|||||||
* @return 过滤后的方法数组
|
* @return 过滤后的方法数组
|
||||||
*/
|
*/
|
||||||
public static Method[] getPublicMethods(final Class<?> clazz, final String... excludeMethodNames) {
|
public static Method[] getPublicMethods(final Class<?> clazz, final String... excludeMethodNames) {
|
||||||
final HashSet<String> excludeMethodNameSet = CollUtil.newHashSet(excludeMethodNames);
|
final HashSet<String> excludeMethodNameSet = SetUtil.newHashSet(excludeMethodNames);
|
||||||
return getPublicMethods(clazz, method -> false == excludeMethodNameSet.contains(method.getName()));
|
return getPublicMethods(clazz, method -> false == excludeMethodNameSet.contains(method.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.regex;
|
package cn.hutool.core.regex;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
@@ -45,7 +45,7 @@ public class ReUtil {
|
|||||||
/**
|
/**
|
||||||
* 正则中需要被转义的关键字
|
* 正则中需要被转义的关键字
|
||||||
*/
|
*/
|
||||||
public final static Set<Character> RE_KEYS = CollUtil.newHashSet('$', '(', ')', '*', '+', '.', '[', ']', '?', '\\', '^', '{', '}', '|');
|
public final static Set<Character> RE_KEYS = SetUtil.newHashSet('$', '(', ')', '*', '+', '.', '[', ']', '?', '\\', '^', '{', '}', '|');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得匹配的字符串,获得正则中分组0的内容
|
* 获得匹配的字符串,获得正则中分组0的内容
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package cn.hutool.core.text.dfa;
|
package cn.hutool.core.text.dfa;
|
||||||
|
|
||||||
import java.util.Set;
|
import cn.hutool.core.collection.SetUtil;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过滤词及一些简单处理
|
* 过滤词及一些简单处理
|
||||||
@@ -11,7 +11,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
*/
|
*/
|
||||||
public class StopChar {
|
public class StopChar {
|
||||||
/** 不需要处理的词,如标点符号、空格等 */
|
/** 不需要处理的词,如标点符号、空格等 */
|
||||||
public static final Set<Character> STOP_WORD = CollUtil.newHashSet(' ', '\'', '、', '。', //
|
public static final Set<Character> STOP_WORD = SetUtil.newHashSet(' ', '\'', '、', '。', //
|
||||||
'·', 'ˉ', 'ˇ', '々', '—', '~', '‖', '…', '‘', '’', '“', '”', '〔', '〕', '〈', '〉', '《', '》', '「', '」', '『', //
|
'·', 'ˉ', 'ˇ', '々', '—', '~', '‖', '…', '‘', '’', '“', '”', '〔', '〕', '〈', '〉', '《', '》', '「', '」', '『', //
|
||||||
'』', '〖', '〗', '【', '】', '±', '+', '-', '×', '÷', '∧', '∨', '∑', '∏', '∪', '∩', '∈', '√', '⊥', '⊙', '∫', //
|
'』', '〖', '〗', '【', '】', '±', '+', '-', '×', '÷', '∧', '∨', '∑', '∏', '∪', '∩', '∈', '√', '⊥', '⊙', '∫', //
|
||||||
'∮', '≡', '≌', '≈', '∽', '∝', '≠', '≮', '≯', '≤', '≥', '∞', '∶', '∵', '∴', '∷', '♂', '♀', '°', '′', '〃', //
|
'∮', '≡', '≌', '≈', '∽', '∝', '≠', '≮', '≯', '≤', '≥', '∞', '∶', '∵', '∴', '∷', '♂', '♀', '°', '′', '〃', //
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.hutool.core.text.dfa;
|
package cn.hutool.core.text.dfa;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -85,7 +86,7 @@ public class WordTree extends HashMap<Character, WordTree> {
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public WordTree addWords(final String... words) {
|
public WordTree addWords(final String... words) {
|
||||||
for (final String word : CollUtil.newHashSet(words)) {
|
for (final String word : SetUtil.newHashSet(words)) {
|
||||||
addWord(word);
|
addWord(word);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.collection.UniqueKeySet;
|
import cn.hutool.core.collection.UniqueKeySet;
|
||||||
import cn.hutool.core.comparator.CompareUtil;
|
import cn.hutool.core.comparator.CompareUtil;
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
@@ -1287,7 +1288,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
|||||||
* @since 3.0.9
|
* @since 3.0.9
|
||||||
*/
|
*/
|
||||||
public static <T> T[] toArray(final Iterator<T> iterator, final Class<T> componentType) {
|
public static <T> T[] toArray(final Iterator<T> iterator, final Class<T> componentType) {
|
||||||
return toArray(CollUtil.newArrayList(iterator), componentType);
|
return toArray(ListUtil.toList(iterator), componentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ import java.util.Set;
|
|||||||
public class BooleanUtil {
|
public class BooleanUtil {
|
||||||
|
|
||||||
/** 表示为真的字符串 */
|
/** 表示为真的字符串 */
|
||||||
private static final Set<String> TRUE_SET = CollUtil.newHashSet("true", "yes", "y", "t", "ok", "1", "on", "是", "对", "真", "對", "√");
|
private static final Set<String> TRUE_SET = SetUtil.newHashSet("true", "yes", "y", "t", "ok", "1", "on", "是", "对", "真", "對", "√");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取相反值
|
* 取相反值
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
@@ -1109,7 +1109,7 @@ public class XmlUtil {
|
|||||||
if (value instanceof List) {
|
if (value instanceof List) {
|
||||||
((List<Object>) value).add(newValue);
|
((List<Object>) value).add(newValue);
|
||||||
} else {
|
} else {
|
||||||
result.put(childEle.getNodeName(), CollUtil.newArrayList(value, newValue));
|
result.put(childEle.getNodeName(), ListUtil.toList(value, newValue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.put(childEle.getNodeName(), newValue);
|
result.put(childEle.getNodeName(), newValue);
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ package cn.hutool.core.bean;
|
|||||||
import cn.hutool.core.annotation.Alias;
|
import cn.hutool.core.annotation.Alias;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import cn.hutool.core.bean.copier.ValueProvider;
|
import cn.hutool.core.bean.copier.ValueProvider;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.map.MapBuilder;
|
import cn.hutool.core.map.MapBuilder;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.text.StrUtil;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -285,7 +285,7 @@ public class BeanUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPropertyDescriptorsTest() {
|
public void getPropertyDescriptorsTest() {
|
||||||
final HashSet<Object> set = CollUtil.newHashSet();
|
final HashSet<Object> set = SetUtil.newHashSet();
|
||||||
final PropertyDescriptor[] propertyDescriptors = BeanUtil.getPropertyDescriptors(SubPerson.class);
|
final PropertyDescriptor[] propertyDescriptors = BeanUtil.getPropertyDescriptors(SubPerson.class);
|
||||||
for (final PropertyDescriptor propertyDescriptor : propertyDescriptors) {
|
for (final PropertyDescriptor propertyDescriptor : propertyDescriptors) {
|
||||||
set.add(propertyDescriptor.getName());
|
set.add(propertyDescriptor.getName());
|
||||||
|
|||||||
@@ -35,22 +35,22 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPredicateContains() {
|
public void testPredicateContains() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("bbbbb", "aaaaa", "ccccc");
|
final ArrayList<String> list = ListUtil.toList("bbbbb", "aaaaa", "ccccc");
|
||||||
Assert.assertTrue(CollUtil.contains(list, s -> s.startsWith("a")));
|
Assert.assertTrue(CollUtil.contains(list, s -> s.startsWith("a")));
|
||||||
Assert.assertFalse(CollUtil.contains(list, s -> s.startsWith("d")));
|
Assert.assertFalse(CollUtil.contains(list, s -> s.startsWith("d")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveWithAddIf() {
|
public void testRemoveWithAddIf() {
|
||||||
ArrayList<Integer> list = CollUtil.newArrayList(1, 2, 3);
|
ArrayList<Integer> list = ListUtil.toList(1, 2, 3);
|
||||||
final ArrayList<Integer> exceptRemovedList = CollUtil.newArrayList(2, 3);
|
final ArrayList<Integer> exceptRemovedList = ListUtil.toList(2, 3);
|
||||||
final ArrayList<Integer> exceptResultList = CollUtil.newArrayList(1);
|
final ArrayList<Integer> exceptResultList = ListUtil.toList(1);
|
||||||
|
|
||||||
List<Integer> resultList = CollUtil.removeWithAddIf(list, ele -> 1 == ele);
|
List<Integer> resultList = CollUtil.removeWithAddIf(list, ele -> 1 == ele);
|
||||||
Assert.assertEquals(list, exceptRemovedList);
|
Assert.assertEquals(list, exceptRemovedList);
|
||||||
Assert.assertEquals(resultList, exceptResultList);
|
Assert.assertEquals(resultList, exceptResultList);
|
||||||
|
|
||||||
list = CollUtil.newArrayList(1, 2, 3);
|
list = ListUtil.toList(1, 2, 3);
|
||||||
resultList = new ArrayList<>();
|
resultList = new ArrayList<>();
|
||||||
CollUtil.removeWithAddIf(list, resultList, ele -> 1 == ele);
|
CollUtil.removeWithAddIf(list, resultList, ele -> 1 == ele);
|
||||||
Assert.assertEquals(list, exceptRemovedList);
|
Assert.assertEquals(list, exceptRemovedList);
|
||||||
@@ -59,27 +59,27 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPadLeft() {
|
public void testPadLeft() {
|
||||||
List<String> srcList = CollUtil.newArrayList();
|
List<String> srcList = ListUtil.toList();
|
||||||
List<String> answerList = CollUtil.newArrayList("a", "b");
|
List<String> answerList = ListUtil.toList("a", "b");
|
||||||
CollUtil.padLeft(srcList, 1, "b");
|
CollUtil.padLeft(srcList, 1, "b");
|
||||||
CollUtil.padLeft(srcList, 2, "a");
|
CollUtil.padLeft(srcList, 2, "a");
|
||||||
Assert.assertEquals(srcList, answerList);
|
Assert.assertEquals(srcList, answerList);
|
||||||
|
|
||||||
srcList = CollUtil.newArrayList("a", "b");
|
srcList = ListUtil.toList("a", "b");
|
||||||
answerList = CollUtil.newArrayList("a", "b");
|
answerList = ListUtil.toList("a", "b");
|
||||||
CollUtil.padLeft(srcList, 2, "a");
|
CollUtil.padLeft(srcList, 2, "a");
|
||||||
Assert.assertEquals(srcList, answerList);
|
Assert.assertEquals(srcList, answerList);
|
||||||
|
|
||||||
srcList = CollUtil.newArrayList("c");
|
srcList = ListUtil.toList("c");
|
||||||
answerList = CollUtil.newArrayList("a", "a", "c");
|
answerList = ListUtil.toList("a", "a", "c");
|
||||||
CollUtil.padLeft(srcList, 3, "a");
|
CollUtil.padLeft(srcList, 3, "a");
|
||||||
Assert.assertEquals(srcList, answerList);
|
Assert.assertEquals(srcList, answerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPadRight() {
|
public void testPadRight() {
|
||||||
final List<String> srcList = CollUtil.newArrayList("a");
|
final List<String> srcList = ListUtil.toList("a");
|
||||||
final List<String> answerList = CollUtil.newArrayList("a", "b", "b", "b", "b");
|
final List<String> answerList = ListUtil.toList("a", "b", "b", "b", "b");
|
||||||
CollUtil.padRight(srcList, 5, "b");
|
CollUtil.padRight(srcList, 5, "b");
|
||||||
Assert.assertEquals(srcList, answerList);
|
Assert.assertEquals(srcList, answerList);
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void newHashSetTest() {
|
public void newHashSetTest() {
|
||||||
final Set<String> set = CollUtil.newHashSet((String[]) null);
|
final Set<String> set = SetUtil.newHashSet((String[]) null);
|
||||||
Assert.assertNotNull(set);
|
Assert.assertNotNull(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,8 +114,8 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unionTest() {
|
public void unionTest() {
|
||||||
final ArrayList<String> list1 = CollUtil.newArrayList("a", "b", "b", "c", "d", "x");
|
final ArrayList<String> list1 = ListUtil.toList("a", "b", "b", "c", "d", "x");
|
||||||
final ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d");
|
final ArrayList<String> list2 = ListUtil.toList("a", "b", "b", "b", "c", "d");
|
||||||
|
|
||||||
final Collection<String> union = CollUtil.union(list1, list2);
|
final Collection<String> union = CollUtil.union(list1, list2);
|
||||||
|
|
||||||
@@ -124,8 +124,8 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void intersectionTest() {
|
public void intersectionTest() {
|
||||||
final ArrayList<String> list1 = CollUtil.newArrayList("a", "b", "b", "c", "d", "x");
|
final ArrayList<String> list1 = ListUtil.toList("a", "b", "b", "c", "d", "x");
|
||||||
final ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d");
|
final ArrayList<String> list2 = ListUtil.toList("a", "b", "b", "b", "c", "d");
|
||||||
|
|
||||||
final Collection<String> intersection = CollUtil.intersection(list1, list2);
|
final Collection<String> intersection = CollUtil.intersection(list1, list2);
|
||||||
Assert.assertEquals(2, CollUtil.count(intersection, "b"::equals));
|
Assert.assertEquals(2, CollUtil.count(intersection, "b"::equals));
|
||||||
@@ -133,12 +133,12 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void intersectionDistinctTest() {
|
public void intersectionDistinctTest() {
|
||||||
final ArrayList<String> list1 = CollUtil.newArrayList("a", "b", "b", "c", "d", "x");
|
final ArrayList<String> list1 = ListUtil.toList("a", "b", "b", "c", "d", "x");
|
||||||
final ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d");
|
final ArrayList<String> list2 = ListUtil.toList("a", "b", "b", "b", "c", "d");
|
||||||
final ArrayList<String> list3 = CollUtil.newArrayList();
|
final ArrayList<String> list3 = ListUtil.toList();
|
||||||
|
|
||||||
final Collection<String> intersectionDistinct = CollUtil.intersectionDistinct(list1, list2);
|
final Collection<String> intersectionDistinct = CollUtil.intersectionDistinct(list1, list2);
|
||||||
Assert.assertEquals(CollUtil.newLinkedHashSet("a", "b", "c", "d"), intersectionDistinct);
|
Assert.assertEquals(SetUtil.newLinkedHashSet("a", "b", "c", "d"), intersectionDistinct);
|
||||||
|
|
||||||
final Collection<String> intersectionDistinct2 = CollUtil.intersectionDistinct(list1, list2, list3);
|
final Collection<String> intersectionDistinct2 = CollUtil.intersectionDistinct(list1, list2, list3);
|
||||||
Assert.assertTrue(intersectionDistinct2.isEmpty());
|
Assert.assertTrue(intersectionDistinct2.isEmpty());
|
||||||
@@ -146,8 +146,8 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disjunctionTest() {
|
public void disjunctionTest() {
|
||||||
final ArrayList<String> list1 = CollUtil.newArrayList("a", "b", "b", "c", "d", "x");
|
final ArrayList<String> list1 = ListUtil.toList("a", "b", "b", "c", "d", "x");
|
||||||
final ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d", "x2");
|
final ArrayList<String> list2 = ListUtil.toList("a", "b", "b", "b", "c", "d", "x2");
|
||||||
|
|
||||||
final Collection<String> disjunction = CollUtil.disjunction(list1, list2);
|
final Collection<String> disjunction = CollUtil.disjunction(list1, list2);
|
||||||
Assert.assertTrue(disjunction.contains("b"));
|
Assert.assertTrue(disjunction.contains("b"));
|
||||||
@@ -163,8 +163,8 @@ public class CollUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void disjunctionTest2() {
|
public void disjunctionTest2() {
|
||||||
// 任意一个集合为空,差集为另一个集合
|
// 任意一个集合为空,差集为另一个集合
|
||||||
final ArrayList<String> list1 = CollUtil.newArrayList();
|
final ArrayList<String> list1 = ListUtil.toList();
|
||||||
final ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d", "x2");
|
final ArrayList<String> list2 = ListUtil.toList("a", "b", "b", "b", "c", "d", "x2");
|
||||||
|
|
||||||
final Collection<String> disjunction = CollUtil.disjunction(list1, list2);
|
final Collection<String> disjunction = CollUtil.disjunction(list1, list2);
|
||||||
Assert.assertEquals(list2, disjunction);
|
Assert.assertEquals(list2, disjunction);
|
||||||
@@ -175,8 +175,8 @@ public class CollUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void disjunctionTest3() {
|
public void disjunctionTest3() {
|
||||||
// 无交集下返回共同的元素
|
// 无交集下返回共同的元素
|
||||||
final ArrayList<String> list1 = CollUtil.newArrayList("1", "2", "3");
|
final ArrayList<String> list1 = ListUtil.toList("1", "2", "3");
|
||||||
final ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "c");
|
final ArrayList<String> list2 = ListUtil.toList("a", "b", "c");
|
||||||
|
|
||||||
final Collection<String> disjunction = CollUtil.disjunction(list1, list2);
|
final Collection<String> disjunction = CollUtil.disjunction(list1, list2);
|
||||||
Assert.assertTrue(disjunction.contains("1"));
|
Assert.assertTrue(disjunction.contains("1"));
|
||||||
@@ -196,8 +196,8 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subtractTest() {
|
public void subtractTest() {
|
||||||
final List<String> list1 = CollUtil.newArrayList("a", "b", "b", "c", "d", "x");
|
final List<String> list1 = ListUtil.toList("a", "b", "b", "c", "d", "x");
|
||||||
final List<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d", "x2");
|
final List<String> list2 = ListUtil.toList("a", "b", "b", "b", "c", "d", "x2");
|
||||||
final Collection<String> subtract = CollUtil.subtract(list1, list2);
|
final Collection<String> subtract = CollUtil.subtract(list1, list2);
|
||||||
Assert.assertEquals(1, subtract.size());
|
Assert.assertEquals(1, subtract.size());
|
||||||
Assert.assertEquals("x", subtract.iterator().next());
|
Assert.assertEquals("x", subtract.iterator().next());
|
||||||
@@ -236,7 +236,7 @@ public class CollUtilTest {
|
|||||||
map2.put("c", "值3");
|
map2.put("c", "值3");
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
final ArrayList<HashMap<String, String>> list = CollUtil.newArrayList(map1, map2);
|
final ArrayList<HashMap<String, String>> list = ListUtil.toList(map1, map2);
|
||||||
final Map<String, List<String>> map = CollUtil.toListMap(list);
|
final Map<String, List<String>> map = CollUtil.toListMap(list);
|
||||||
Assert.assertEquals("值1", map.get("a").get(0));
|
Assert.assertEquals("值1", map.get("a").get(0));
|
||||||
Assert.assertEquals("值2", map.get("a").get(1));
|
Assert.assertEquals("值2", map.get("a").get(1));
|
||||||
@@ -251,7 +251,7 @@ public class CollUtilTest {
|
|||||||
public void getFieldValuesTest() {
|
public void getFieldValuesTest() {
|
||||||
final Dict v1 = Dict.create().set("id", 12).set("name", "张三").set("age", 23);
|
final Dict v1 = Dict.create().set("id", 12).set("name", "张三").set("age", 23);
|
||||||
final Dict v2 = Dict.create().set("age", 13).set("id", 15).set("name", "李四");
|
final Dict v2 = Dict.create().set("age", 13).set("id", 15).set("name", "李四");
|
||||||
final ArrayList<Dict> list = CollUtil.newArrayList(v1, v2);
|
final ArrayList<Dict> list = ListUtil.toList(v1, v2);
|
||||||
|
|
||||||
final List<Object> fieldValues = CollUtil.getFieldValues(list, "name");
|
final List<Object> fieldValues = CollUtil.getFieldValues(list, "name");
|
||||||
Assert.assertEquals("张三", fieldValues.get(0));
|
Assert.assertEquals("张三", fieldValues.get(0));
|
||||||
@@ -260,7 +260,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void splitTest() {
|
public void splitTest() {
|
||||||
final ArrayList<Integer> list = CollUtil.newArrayList(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
final ArrayList<Integer> list = ListUtil.toList(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||||
final List<List<Integer>> split = CollUtil.split(list, 3);
|
final List<List<Integer>> split = CollUtil.split(list, 3);
|
||||||
Assert.assertEquals(3, split.size());
|
Assert.assertEquals(3, split.size());
|
||||||
Assert.assertEquals(3, split.get(0).size());
|
Assert.assertEquals(3, split.get(0).size());
|
||||||
@@ -285,35 +285,35 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void filterTest() {
|
public void filterTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c");
|
||||||
|
|
||||||
final Collection<String> filtered = CollUtil.edit(list, t -> t + 1);
|
final Collection<String> filtered = CollUtil.edit(list, t -> t + 1);
|
||||||
|
|
||||||
Assert.assertEquals(CollUtil.newArrayList("a1", "b1", "c1"), filtered);
|
Assert.assertEquals(ListUtil.toList("a1", "b1", "c1"), filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void filterTest2() {
|
public void filterTest2() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c");
|
||||||
|
|
||||||
final ArrayList<String> filtered = CollUtil.filter(list, t -> false == "a".equals(t));
|
final ArrayList<String> filtered = CollUtil.filter(list, t -> false == "a".equals(t));
|
||||||
|
|
||||||
// 原地过滤
|
// 原地过滤
|
||||||
Assert.assertSame(list, filtered);
|
Assert.assertSame(list, filtered);
|
||||||
Assert.assertEquals(CollUtil.newArrayList("b", "c"), filtered);
|
Assert.assertEquals(ListUtil.toList("b", "c"), filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void filterSetTest() {
|
public void filterSetTest() {
|
||||||
final Set<String> set = CollUtil.newLinkedHashSet("a", "b", "", " ", "c");
|
final Set<String> set = SetUtil.newLinkedHashSet("a", "b", "", " ", "c");
|
||||||
final Set<String> filtered = CollUtil.filter(set, StrUtil::isNotBlank);
|
final Set<String> filtered = CollUtil.filter(set, StrUtil::isNotBlank);
|
||||||
|
|
||||||
Assert.assertEquals(CollUtil.newLinkedHashSet("a", "b", "c"), filtered);
|
Assert.assertEquals(SetUtil.newLinkedHashSet("a", "b", "c"), filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void filterRemoveTest() {
|
public void filterRemoveTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c");
|
||||||
|
|
||||||
final List<String> removed = new ArrayList<>();
|
final List<String> removed = new ArrayList<>();
|
||||||
final ArrayList<String> filtered = CollUtil.filter(list, t -> {
|
final ArrayList<String> filtered = CollUtil.filter(list, t -> {
|
||||||
@@ -329,45 +329,45 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
// 原地过滤
|
// 原地过滤
|
||||||
Assert.assertSame(list, filtered);
|
Assert.assertSame(list, filtered);
|
||||||
Assert.assertEquals(CollUtil.newArrayList("b", "c"), filtered);
|
Assert.assertEquals(ListUtil.toList("b", "c"), filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeNullTest() {
|
public void removeNullTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c", null, "", " ");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c", null, "", " ");
|
||||||
|
|
||||||
final ArrayList<String> filtered = CollUtil.removeNull(list);
|
final ArrayList<String> filtered = CollUtil.removeNull(list);
|
||||||
|
|
||||||
// 原地过滤
|
// 原地过滤
|
||||||
Assert.assertSame(list, filtered);
|
Assert.assertSame(list, filtered);
|
||||||
Assert.assertEquals(CollUtil.newArrayList("a", "b", "c", "", " "), filtered);
|
Assert.assertEquals(ListUtil.toList("a", "b", "c", "", " "), filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeEmptyTest() {
|
public void removeEmptyTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c", null, "", " ");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c", null, "", " ");
|
||||||
|
|
||||||
final ArrayList<String> filtered = CollUtil.removeEmpty(list);
|
final ArrayList<String> filtered = CollUtil.removeEmpty(list);
|
||||||
|
|
||||||
// 原地过滤
|
// 原地过滤
|
||||||
Assert.assertSame(list, filtered);
|
Assert.assertSame(list, filtered);
|
||||||
Assert.assertEquals(CollUtil.newArrayList("a", "b", "c", " "), filtered);
|
Assert.assertEquals(ListUtil.toList("a", "b", "c", " "), filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeBlankTest() {
|
public void removeBlankTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c", null, "", " ");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c", null, "", " ");
|
||||||
|
|
||||||
final ArrayList<String> filtered = CollUtil.removeBlank(list);
|
final ArrayList<String> filtered = CollUtil.removeBlank(list);
|
||||||
|
|
||||||
// 原地过滤
|
// 原地过滤
|
||||||
Assert.assertSame(list, filtered);
|
Assert.assertSame(list, filtered);
|
||||||
Assert.assertEquals(CollUtil.newArrayList("a", "b", "c"), filtered);
|
Assert.assertEquals(ListUtil.toList("a", "b", "c"), filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void groupTest() {
|
public void groupTest() {
|
||||||
final List<String> list = CollUtil.newArrayList("1", "2", "3", "4", "5", "6");
|
final List<String> list = ListUtil.toList("1", "2", "3", "4", "5", "6");
|
||||||
final List<List<String>> group = CollUtil.group(list, null);
|
final List<List<String>> group = CollUtil.group(list, null);
|
||||||
Assert.assertTrue(group.size() > 0);
|
Assert.assertTrue(group.size() > 0);
|
||||||
|
|
||||||
@@ -375,13 +375,13 @@ public class CollUtilTest {
|
|||||||
// 按照奇数偶数分类
|
// 按照奇数偶数分类
|
||||||
return Integer.parseInt(t) % 2;
|
return Integer.parseInt(t) % 2;
|
||||||
});
|
});
|
||||||
Assert.assertEquals(CollUtil.newArrayList("2", "4", "6"), group2.get(0));
|
Assert.assertEquals(ListUtil.toList("2", "4", "6"), group2.get(0));
|
||||||
Assert.assertEquals(CollUtil.newArrayList("1", "3", "5"), group2.get(1));
|
Assert.assertEquals(ListUtil.toList("1", "3", "5"), group2.get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void groupByFieldTest() {
|
public void groupByFieldTest() {
|
||||||
final List<TestBean> list = CollUtil.newArrayList(new TestBean("张三", 12), new TestBean("李四", 13), new TestBean("王五", 12));
|
final List<TestBean> list = ListUtil.toList(new TestBean("张三", 12), new TestBean("李四", 13), new TestBean("王五", 12));
|
||||||
final List<List<TestBean>> groupByField = CollUtil.groupByField(list, "age");
|
final List<List<TestBean>> groupByField = CollUtil.groupByField(list, "age");
|
||||||
Assert.assertEquals("张三", groupByField.get(0).get(0).getName());
|
Assert.assertEquals("张三", groupByField.get(0).get(0).getName());
|
||||||
Assert.assertEquals("王五", groupByField.get(0).get(1).getName());
|
Assert.assertEquals("王五", groupByField.get(0).get(1).getName());
|
||||||
@@ -391,7 +391,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sortByPropertyTest() {
|
public void sortByPropertyTest() {
|
||||||
final List<TestBean> list = CollUtil.newArrayList(
|
final List<TestBean> list = ListUtil.toList(
|
||||||
new TestBean("张三", 12, DateUtil.parse("2018-05-01")), //
|
new TestBean("张三", 12, DateUtil.parse("2018-05-01")), //
|
||||||
new TestBean("李四", 13, DateUtil.parse("2018-03-01")), //
|
new TestBean("李四", 13, DateUtil.parse("2018-03-01")), //
|
||||||
new TestBean("王五", 12, DateUtil.parse("2018-04-01"))//
|
new TestBean("王五", 12, DateUtil.parse("2018-04-01"))//
|
||||||
@@ -405,7 +405,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sortByPropertyTest2() {
|
public void sortByPropertyTest2() {
|
||||||
final List<TestBean> list = CollUtil.newArrayList(
|
final List<TestBean> list = ListUtil.toList(
|
||||||
new TestBean("张三", 0, DateUtil.parse("2018-05-01")), //
|
new TestBean("张三", 0, DateUtil.parse("2018-05-01")), //
|
||||||
new TestBean("李四", -12, DateUtil.parse("2018-03-01")), //
|
new TestBean("李四", -12, DateUtil.parse("2018-03-01")), //
|
||||||
new TestBean("王五", 23, DateUtil.parse("2018-04-01"))//
|
new TestBean("王五", 23, DateUtil.parse("2018-04-01"))//
|
||||||
@@ -419,7 +419,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fieldValueMapTest() {
|
public void fieldValueMapTest() {
|
||||||
final List<TestBean> list = CollUtil.newArrayList(new TestBean("张三", 12, DateUtil.parse("2018-05-01")), //
|
final List<TestBean> list = ListUtil.toList(new TestBean("张三", 12, DateUtil.parse("2018-05-01")), //
|
||||||
new TestBean("李四", 13, DateUtil.parse("2018-03-01")), //
|
new TestBean("李四", 13, DateUtil.parse("2018-03-01")), //
|
||||||
new TestBean("王五", 12, DateUtil.parse("2018-04-01"))//
|
new TestBean("王五", 12, DateUtil.parse("2018-04-01"))//
|
||||||
);
|
);
|
||||||
@@ -432,7 +432,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fieldValueAsMapTest() {
|
public void fieldValueAsMapTest() {
|
||||||
final List<TestBean> list = CollUtil.newArrayList(new TestBean("张三", 12, DateUtil.parse("2018-05-01")), //
|
final List<TestBean> list = ListUtil.toList(new TestBean("张三", 12, DateUtil.parse("2018-05-01")), //
|
||||||
new TestBean("李四", 13, DateUtil.parse("2018-03-01")), //
|
new TestBean("李四", 13, DateUtil.parse("2018-03-01")), //
|
||||||
new TestBean("王五", 14, DateUtil.parse("2018-04-01"))//
|
new TestBean("王五", 14, DateUtil.parse("2018-04-01"))//
|
||||||
);
|
);
|
||||||
@@ -470,8 +470,8 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listTest() {
|
public void listTest() {
|
||||||
final List<Object> list1 = CollUtil.list(false);
|
final List<Object> list1 = ListUtil.list(false);
|
||||||
final List<Object> list2 = CollUtil.list(true);
|
final List<Object> list2 = ListUtil.list(true);
|
||||||
|
|
||||||
Assert.assertTrue(list1 instanceof ArrayList);
|
Assert.assertTrue(list1 instanceof ArrayList);
|
||||||
Assert.assertTrue(list2 instanceof LinkedList);
|
Assert.assertTrue(list2 instanceof LinkedList);
|
||||||
@@ -479,8 +479,8 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listTest2() {
|
public void listTest2() {
|
||||||
final List<String> list1 = CollUtil.list(false, "a", "b", "c");
|
final List<String> list1 = ListUtil.list(false, "a", "b", "c");
|
||||||
final List<String> list2 = CollUtil.list(true, "a", "b", "c");
|
final List<String> list2 = ListUtil.list(true, "a", "b", "c");
|
||||||
Assert.assertEquals("[a, b, c]", list1.toString());
|
Assert.assertEquals("[a, b, c]", list1.toString());
|
||||||
Assert.assertEquals("[a, b, c]", list2.toString());
|
Assert.assertEquals("[a, b, c]", list2.toString());
|
||||||
}
|
}
|
||||||
@@ -492,15 +492,15 @@ public class CollUtilTest {
|
|||||||
set.add("b");
|
set.add("b");
|
||||||
set.add("c");
|
set.add("c");
|
||||||
|
|
||||||
final List<String> list1 = CollUtil.list(false, set);
|
final List<String> list1 = ListUtil.list(false, set);
|
||||||
final List<String> list2 = CollUtil.list(true, set);
|
final List<String> list2 = ListUtil.list(true, set);
|
||||||
Assert.assertEquals("[a, b, c]", list1.toString());
|
Assert.assertEquals("[a, b, c]", list1.toString());
|
||||||
Assert.assertEquals("[a, b, c]", list2.toString());
|
Assert.assertEquals("[a, b, c]", list2.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTest() {
|
public void getTest() {
|
||||||
final HashSet<String> set = CollUtil.set(true, "A", "B", "C", "D");
|
final HashSet<String> set = SetUtil.set(true, "A", "B", "C", "D");
|
||||||
String str = CollUtil.get(set, 2);
|
String str = CollUtil.get(set, 2);
|
||||||
Assert.assertEquals("C", str);
|
Assert.assertEquals("C", str);
|
||||||
|
|
||||||
@@ -701,43 +701,43 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sortPageAllTest() {
|
public void sortPageAllTest() {
|
||||||
final List<Integer> list = CollUtil.newArrayList(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
final List<Integer> list = ListUtil.toList(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||||
final List<Integer> sortPageAll = CollUtil.sortPageAll(1, 5, Comparator.reverseOrder(), list);
|
final List<Integer> sortPageAll = CollUtil.sortPageAll(1, 5, Comparator.reverseOrder(), list);
|
||||||
|
|
||||||
Assert.assertEquals(CollUtil.newArrayList(4, 3, 2, 1), sortPageAll);
|
Assert.assertEquals(ListUtil.toList(4, 3, 2, 1), sortPageAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containsAnyTest() {
|
public void containsAnyTest() {
|
||||||
final ArrayList<Integer> list1 = CollUtil.newArrayList(1, 2, 3, 4, 5);
|
final ArrayList<Integer> list1 = ListUtil.toList(1, 2, 3, 4, 5);
|
||||||
final ArrayList<Integer> list2 = CollUtil.newArrayList(5, 3, 1, 9, 11);
|
final ArrayList<Integer> list2 = ListUtil.toList(5, 3, 1, 9, 11);
|
||||||
|
|
||||||
Assert.assertTrue(CollUtil.containsAny(list1, list2));
|
Assert.assertTrue(CollUtil.containsAny(list1, list2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containsAllTest() {
|
public void containsAllTest() {
|
||||||
final ArrayList<Integer> list1 = CollUtil.newArrayList(1, 2, 3, 4, 5);
|
final ArrayList<Integer> list1 = ListUtil.toList(1, 2, 3, 4, 5);
|
||||||
final ArrayList<Integer> list2 = CollUtil.newArrayList(5, 3, 1);
|
final ArrayList<Integer> list2 = ListUtil.toList(5, 3, 1);
|
||||||
Assert.assertTrue(CollUtil.containsAll(list1, list2));
|
Assert.assertTrue(CollUtil.containsAll(list1, list2));
|
||||||
|
|
||||||
final ArrayList<Integer> list3 = CollUtil.newArrayList(1);
|
final ArrayList<Integer> list3 = ListUtil.toList(1);
|
||||||
final ArrayList<Integer> list4 = CollUtil.newArrayList();
|
final ArrayList<Integer> list4 = ListUtil.toList();
|
||||||
Assert.assertTrue(CollUtil.containsAll(list3, list4));
|
Assert.assertTrue(CollUtil.containsAll(list3, list4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getLastTest() {
|
public void getLastTest() {
|
||||||
// 测试:空数组返回null而不是报错
|
// 测试:空数组返回null而不是报错
|
||||||
final List<String> test = CollUtil.newArrayList();
|
final List<String> test = ListUtil.toList();
|
||||||
final String last = CollUtil.getLast(test);
|
final String last = CollUtil.getLast(test);
|
||||||
Assert.assertNull(last);
|
Assert.assertNull(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void zipTest() {
|
public void zipTest() {
|
||||||
final Collection<String> keys = CollUtil.newArrayList("a", "b", "c", "d");
|
final Collection<String> keys = ListUtil.toList("a", "b", "c", "d");
|
||||||
final Collection<Integer> values = CollUtil.newArrayList(1, 2, 3, 4);
|
final Collection<Integer> values = ListUtil.toList(1, 2, 3, 4);
|
||||||
|
|
||||||
final Map<String, Integer> map = CollUtil.zip(keys, values);
|
final Map<String, Integer> map = CollUtil.zip(keys, values);
|
||||||
|
|
||||||
@@ -751,7 +751,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toMapTest() {
|
public void toMapTest() {
|
||||||
final Collection<String> keys = CollUtil.newArrayList("a", "b", "c", "d");
|
final Collection<String> keys = ListUtil.toList("a", "b", "c", "d");
|
||||||
final Map<String, String> map = CollUtil.toMap(keys, new HashMap<>(), (value) -> "key" + value);
|
final Map<String, String> map = CollUtil.toMap(keys, new HashMap<>(), (value) -> "key" + value);
|
||||||
Assert.assertEquals("a", map.get("keya"));
|
Assert.assertEquals("a", map.get("keya"));
|
||||||
Assert.assertEquals("b", map.get("keyb"));
|
Assert.assertEquals("b", map.get("keyb"));
|
||||||
@@ -778,7 +778,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void countMapTest() {
|
public void countMapTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c", "c", "a", "b", "d");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c", "c", "a", "b", "d");
|
||||||
final Map<String, Integer> countMap = CollUtil.countMap(list);
|
final Map<String, Integer> countMap = CollUtil.countMap(list);
|
||||||
|
|
||||||
Assert.assertEquals(Integer.valueOf(2), countMap.get("a"));
|
Assert.assertEquals(Integer.valueOf(2), countMap.get("a"));
|
||||||
@@ -789,7 +789,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void indexOfTest() {
|
public void indexOfTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c", "c", "a", "b", "d");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c", "c", "a", "b", "d");
|
||||||
final int i = CollUtil.indexOf(list, (str) -> str.charAt(0) == 'c');
|
final int i = CollUtil.indexOf(list, (str) -> str.charAt(0) == 'c');
|
||||||
Assert.assertEquals(2, i);
|
Assert.assertEquals(2, i);
|
||||||
}
|
}
|
||||||
@@ -797,14 +797,14 @@ public class CollUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void lastIndexOfTest() {
|
public void lastIndexOfTest() {
|
||||||
// List有优化
|
// List有优化
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("a", "b", "c", "c", "a", "b", "d");
|
final ArrayList<String> list = ListUtil.toList("a", "b", "c", "c", "a", "b", "d");
|
||||||
final int i = CollUtil.lastIndexOf(list, (str) -> str.charAt(0) == 'c');
|
final int i = CollUtil.lastIndexOf(list, (str) -> str.charAt(0) == 'c');
|
||||||
Assert.assertEquals(3, i);
|
Assert.assertEquals(3, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lastIndexOfSetTest() {
|
public void lastIndexOfSetTest() {
|
||||||
final Set<String> list = CollUtil.set(true, "a", "b", "c", "c", "a", "b", "d");
|
final Set<String> list = SetUtil.set(true, "a", "b", "c", "c", "a", "b", "d");
|
||||||
// 去重后c排第三
|
// 去重后c排第三
|
||||||
final int i = CollUtil.lastIndexOf(list, (str) -> str.charAt(0) == 'c');
|
final int i = CollUtil.lastIndexOf(list, (str) -> str.charAt(0) == 'c');
|
||||||
Assert.assertEquals(2, i);
|
Assert.assertEquals(2, i);
|
||||||
@@ -812,7 +812,7 @@ public class CollUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pageTest() {
|
public void pageTest() {
|
||||||
final List<Dict> objects = CollUtil.newArrayList();
|
final List<Dict> objects = ListUtil.toList();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
objects.add(Dict.create().set("name", "姓名:" + i));
|
objects.add(Dict.create().set("name", "姓名:" + i));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ public class IterUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getFirstNonNullTest(){
|
public void getFirstNonNullTest(){
|
||||||
final ArrayList<String> strings = CollUtil.newArrayList(null, null, "123", "456", null);
|
final ArrayList<String> strings = ListUtil.toList(null, null, "123", "456", null);
|
||||||
Assert.assertEquals("123", IterUtil.getFirstNoneNull(strings));
|
Assert.assertEquals("123", IterUtil.getFirstNoneNull(strings));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fieldValueMapTest() {
|
public void fieldValueMapTest() {
|
||||||
final ArrayList<Car> carList = CollUtil.newArrayList(new Car("123", "大众"), new Car("345", "奔驰"), new Car("567", "路虎"));
|
final ArrayList<Car> carList = ListUtil.toList(new Car("123", "大众"), new Car("345", "奔驰"), new Car("567", "路虎"));
|
||||||
final Map<String, Car> carNameMap = IterUtil.fieldValueMap(carList.iterator(), "carNumber");
|
final Map<String, Car> carNameMap = IterUtil.fieldValueMap(carList.iterator(), "carNumber");
|
||||||
|
|
||||||
Assert.assertEquals("大众", carNameMap.get("123").getCarName());
|
Assert.assertEquals("大众", carNameMap.get("123").getCarName());
|
||||||
@@ -40,30 +40,30 @@ public class IterUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void joinTest() {
|
public void joinTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("1", "2", "3", "4");
|
final ArrayList<String> list = ListUtil.toList("1", "2", "3", "4");
|
||||||
final String join = IterUtil.join(list.iterator(), ":");
|
final String join = IterUtil.join(list.iterator(), ":");
|
||||||
Assert.assertEquals("1:2:3:4", join);
|
Assert.assertEquals("1:2:3:4", join);
|
||||||
|
|
||||||
final ArrayList<Integer> list1 = CollUtil.newArrayList(1, 2, 3, 4);
|
final ArrayList<Integer> list1 = ListUtil.toList(1, 2, 3, 4);
|
||||||
final String join1 = IterUtil.join(list1.iterator(), ":");
|
final String join1 = IterUtil.join(list1.iterator(), ":");
|
||||||
Assert.assertEquals("1:2:3:4", join1);
|
Assert.assertEquals("1:2:3:4", join1);
|
||||||
|
|
||||||
// 包装每个节点
|
// 包装每个节点
|
||||||
final ArrayList<String> list2 = CollUtil.newArrayList("1", "2", "3", "4");
|
final ArrayList<String> list2 = ListUtil.toList("1", "2", "3", "4");
|
||||||
final String join2 = IterUtil.join(list2.iterator(), ":", "\"", "\"");
|
final String join2 = IterUtil.join(list2.iterator(), ":", "\"", "\"");
|
||||||
Assert.assertEquals("\"1\":\"2\":\"3\":\"4\"", join2);
|
Assert.assertEquals("\"1\":\"2\":\"3\":\"4\"", join2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void joinWithFuncTest() {
|
public void joinWithFuncTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("1", "2", "3", "4");
|
final ArrayList<String> list = ListUtil.toList("1", "2", "3", "4");
|
||||||
final String join = IterUtil.join(list.iterator(), ":", String::valueOf);
|
final String join = IterUtil.join(list.iterator(), ":", String::valueOf);
|
||||||
Assert.assertEquals("1:2:3:4", join);
|
Assert.assertEquals("1:2:3:4", join);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void joinWithNullTest() {
|
public void joinWithNullTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("1", null, "3", "4");
|
final ArrayList<String> list = ListUtil.toList("1", null, "3", "4");
|
||||||
final String join = IterUtil.join(list.iterator(), ":", String::valueOf);
|
final String join = IterUtil.join(list.iterator(), ":", String::valueOf);
|
||||||
Assert.assertEquals("1:null:3:4", join);
|
Assert.assertEquals("1:null:3:4", join);
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ public class IterUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTest() {
|
public void getTest() {
|
||||||
final HashSet<String> set = CollUtil.set(true, "A", "B", "C", "D");
|
final HashSet<String> set = SetUtil.set(true, "A", "B", "C", "D");
|
||||||
final String str = IterUtil.get(set.iterator(), 2);
|
final String str = IterUtil.get(set.iterator(), 2);
|
||||||
Assert.assertEquals("C", str);
|
Assert.assertEquals("C", str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package cn.hutool.core.convert;
|
package cn.hutool.core.convert;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.codec.HexUtil;
|
||||||
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.date.DateException;
|
import cn.hutool.core.date.DateException;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.reflect.TypeReference;
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.reflect.TypeReference;
|
||||||
import cn.hutool.core.util.ByteUtil;
|
import cn.hutool.core.util.ByteUtil;
|
||||||
import cn.hutool.core.codec.HexUtil;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -293,7 +293,7 @@ public class ConvertTest {
|
|||||||
public void toSetTest(){
|
public void toSetTest(){
|
||||||
final Set<Integer> result = Convert.convert(new TypeReference<Set<Integer>>() {
|
final Set<Integer> result = Convert.convert(new TypeReference<Set<Integer>>() {
|
||||||
}, "1,2,3");
|
}, "1,2,3");
|
||||||
Assert.assertEquals(CollUtil.set(false, 1,2,3), result);
|
Assert.assertEquals(SetUtil.set(false, 1,2,3), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.convert;
|
package cn.hutool.core.convert;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.reflect.TypeReference;
|
import cn.hutool.core.reflect.TypeReference;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -128,7 +128,7 @@ public class ConvertToCollectionTest {
|
|||||||
public void toSetTest() {
|
public void toSetTest() {
|
||||||
final Object[] a = { "a", "你", "好", "", 1 };
|
final Object[] a = { "a", "你", "好", "", 1 };
|
||||||
final LinkedHashSet<?> set = Convert.convert(LinkedHashSet.class, a);
|
final LinkedHashSet<?> set = Convert.convert(LinkedHashSet.class, a);
|
||||||
final ArrayList<?> list = CollUtil.newArrayList(set);
|
final ArrayList<?> list = ListUtil.toList(set);
|
||||||
Assert.assertEquals("a", list.get(0));
|
Assert.assertEquals("a", list.get(0));
|
||||||
Assert.assertEquals("你", list.get(1));
|
Assert.assertEquals("你", list.get(1));
|
||||||
Assert.assertEquals("好", list.get(2));
|
Assert.assertEquals("好", list.get(2));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.date;
|
package cn.hutool.core.date;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.BetweenFormatter.Level;
|
import cn.hutool.core.date.BetweenFormatter.Level;
|
||||||
import cn.hutool.core.date.format.FastDateFormat;
|
import cn.hutool.core.date.format.FastDateFormat;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
@@ -800,13 +800,13 @@ public class DateUtilTest {
|
|||||||
Assert.assertEquals("20184", yearAndQuarter);
|
Assert.assertEquals("20184", yearAndQuarter);
|
||||||
|
|
||||||
final LinkedHashSet<String> yearAndQuarters = DateUtil.yearAndQuarter(DateUtil.parse("2018-09-10"), DateUtil.parse("2018-12-20"));
|
final LinkedHashSet<String> yearAndQuarters = DateUtil.yearAndQuarter(DateUtil.parse("2018-09-10"), DateUtil.parse("2018-12-20"));
|
||||||
final List<String> list = CollUtil.list(false, yearAndQuarters);
|
final List<String> list = ListUtil.list(false, yearAndQuarters);
|
||||||
Assert.assertEquals(2, list.size());
|
Assert.assertEquals(2, list.size());
|
||||||
Assert.assertEquals("20183", list.get(0));
|
Assert.assertEquals("20183", list.get(0));
|
||||||
Assert.assertEquals("20184", list.get(1));
|
Assert.assertEquals("20184", list.get(1));
|
||||||
|
|
||||||
final LinkedHashSet<String> yearAndQuarters2 = DateUtil.yearAndQuarter(DateUtil.parse("2018-10-10"), DateUtil.parse("2018-12-10"));
|
final LinkedHashSet<String> yearAndQuarters2 = DateUtil.yearAndQuarter(DateUtil.parse("2018-10-10"), DateUtil.parse("2018-12-10"));
|
||||||
final List<String> list2 = CollUtil.list(false, yearAndQuarters2);
|
final List<String> list2 = ListUtil.list(false, yearAndQuarters2);
|
||||||
Assert.assertEquals(1, list2.size());
|
Assert.assertEquals(1, list2.size());
|
||||||
Assert.assertEquals("20184", list2.get(0));
|
Assert.assertEquals("20184", list2.get(0));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package cn.hutool.core.lang;
|
package cn.hutool.core.lang;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
|
|
||||||
public class WeightRandomTest {
|
public class WeightRandomTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -15,6 +14,6 @@ public class WeightRandomTest {
|
|||||||
random.add("C", 100);
|
random.add("C", 100);
|
||||||
|
|
||||||
final String result = random.next();
|
final String result = random.next();
|
||||||
Assert.assertTrue(CollUtil.newArrayList("A", "B", "C").contains(result));
|
Assert.assertTrue(ListUtil.toList("A", "B", "C").contains(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.hutool.core.text;
|
package cn.hutool.core.text;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ public class StrJoinerTest {
|
|||||||
public void joinMultiArrayTest(){
|
public void joinMultiArrayTest(){
|
||||||
final StrJoiner append = StrJoiner.of(",");
|
final StrJoiner append = StrJoiner.of(",");
|
||||||
append.append(new Object[]{ListUtil.of("1", "2"),
|
append.append(new Object[]{ListUtil.of("1", "2"),
|
||||||
CollUtil.newLinkedHashSet("3", "4")
|
SetUtil.newLinkedHashSet("3", "4")
|
||||||
});
|
});
|
||||||
Assert.assertEquals("1,2,3,4", append.toString());
|
Assert.assertEquals("1,2,3,4", append.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.text.dfa;
|
package cn.hutool.core.text.dfa;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ public class DfaTest {
|
|||||||
// 匹配到【大】,就不再继续匹配了,因此【大土豆】不匹配
|
// 匹配到【大】,就不再继续匹配了,因此【大土豆】不匹配
|
||||||
// 匹配到【刚出锅】,就跳过这三个字了,因此【出锅】不匹配(由于刚首先被匹配,因此长的被匹配,最短匹配只针对第一个字相同选最短)
|
// 匹配到【刚出锅】,就跳过这三个字了,因此【出锅】不匹配(由于刚首先被匹配,因此长的被匹配,最短匹配只针对第一个字相同选最短)
|
||||||
final List<String> matchAll = tree.matchAll(text, -1, false, false);
|
final List<String> matchAll = tree.matchAll(text, -1, false, false);
|
||||||
Assert.assertEquals(matchAll, CollUtil.newArrayList("大", "土^豆", "刚出锅"));
|
Assert.assertEquals(matchAll, ListUtil.toList("大", "土^豆", "刚出锅"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,7 +43,7 @@ public class DfaTest {
|
|||||||
// 【大】被匹配,最短匹配原则【大土豆】被跳过,【土豆继续被匹配】
|
// 【大】被匹配,最短匹配原则【大土豆】被跳过,【土豆继续被匹配】
|
||||||
// 【刚出锅】被匹配,由于不跳过已经匹配的词,【出锅】被匹配
|
// 【刚出锅】被匹配,由于不跳过已经匹配的词,【出锅】被匹配
|
||||||
final List<String> matchAll = tree.matchAll(text, -1, true, false);
|
final List<String> matchAll = tree.matchAll(text, -1, true, false);
|
||||||
Assert.assertEquals(matchAll, CollUtil.newArrayList("大", "土^豆", "刚出锅", "出锅"));
|
Assert.assertEquals(matchAll, ListUtil.toList("大", "土^豆", "刚出锅", "出锅"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +59,7 @@ public class DfaTest {
|
|||||||
// 匹配到【大】,由于非密集匹配,因此从下一个字符开始查找,匹配到【土豆】接着被匹配
|
// 匹配到【大】,由于非密集匹配,因此从下一个字符开始查找,匹配到【土豆】接着被匹配
|
||||||
// 由于【刚出锅】被匹配,由于非密集匹配,【出锅】被跳过
|
// 由于【刚出锅】被匹配,由于非密集匹配,【出锅】被跳过
|
||||||
final List<String> matchAll = tree.matchAll(text, -1, false, true);
|
final List<String> matchAll = tree.matchAll(text, -1, false, true);
|
||||||
Assert.assertEquals(matchAll, CollUtil.newArrayList("大", "土^豆", "刚出锅"));
|
Assert.assertEquals(matchAll, ListUtil.toList("大", "土^豆", "刚出锅"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public class DfaTest {
|
|||||||
// 匹配到【大】,由于到最长匹配,因此【大土豆】接着被匹配,由于不跳过已经匹配的关键词,土豆继续被匹配
|
// 匹配到【大】,由于到最长匹配,因此【大土豆】接着被匹配,由于不跳过已经匹配的关键词,土豆继续被匹配
|
||||||
// 【刚出锅】被匹配,由于不跳过已经匹配的词,【出锅】被匹配
|
// 【刚出锅】被匹配,由于不跳过已经匹配的词,【出锅】被匹配
|
||||||
final List<String> matchAll = tree.matchAll(text, -1, true, true);
|
final List<String> matchAll = tree.matchAll(text, -1, true, true);
|
||||||
Assert.assertEquals(matchAll, CollUtil.newArrayList("大", "大土^豆", "土^豆", "刚出锅", "出锅"));
|
Assert.assertEquals(matchAll, ListUtil.toList("大", "大土^豆", "土^豆", "刚出锅", "出锅"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ public class DfaTest {
|
|||||||
tree.addWord("tio");
|
tree.addWord("tio");
|
||||||
|
|
||||||
final List<String> all = tree.matchAll("AAAAAAAt-ioBBBBBBB");
|
final List<String> all = tree.matchAll("AAAAAAAt-ioBBBBBBB");
|
||||||
Assert.assertEquals(all, CollUtil.newArrayList("t-io"));
|
Assert.assertEquals(all, ListUtil.toList("t-io"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
package cn.hutool.core.tree;
|
package cn.hutool.core.tree;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.tree.Tree;
|
|
||||||
import cn.hutool.core.tree.TreeNode;
|
|
||||||
import cn.hutool.core.tree.TreeNodeConfig;
|
|
||||||
import cn.hutool.core.tree.TreeUtil;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -18,7 +14,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class TreeTest {
|
public class TreeTest {
|
||||||
// 模拟数据
|
// 模拟数据
|
||||||
static List<TreeNode<String>> nodeList = CollUtil.newArrayList();
|
static List<TreeNode<String>> nodeList = ListUtil.toList();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// 模拟数据
|
// 模拟数据
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -323,7 +323,7 @@ public class ArrayUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toArrayTest() {
|
public void toArrayTest() {
|
||||||
final ArrayList<String> list = CollUtil.newArrayList("A", "B", "C", "D");
|
final ArrayList<String> list = ListUtil.toList("A", "B", "C", "D");
|
||||||
final String[] array = ArrayUtil.toArray(list, String.class);
|
final String[] array = ArrayUtil.toArray(list, String.class);
|
||||||
Assert.assertEquals("A", array[0]);
|
Assert.assertEquals("A", array[0]);
|
||||||
Assert.assertEquals("B", array[1]);
|
Assert.assertEquals("B", array[1]);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -18,13 +18,13 @@ public class EnumUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getNamesTest() {
|
public void getNamesTest() {
|
||||||
final List<String> names = EnumUtil.getNames(TestEnum.class);
|
final List<String> names = EnumUtil.getNames(TestEnum.class);
|
||||||
Assert.assertEquals(CollUtil.newArrayList("TEST1", "TEST2", "TEST3"), names);
|
Assert.assertEquals(ListUtil.toList("TEST1", "TEST2", "TEST3"), names);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getFieldValuesTest() {
|
public void getFieldValuesTest() {
|
||||||
final List<Object> types = EnumUtil.getFieldValues(TestEnum.class, "type");
|
final List<Object> types = EnumUtil.getFieldValues(TestEnum.class, "type");
|
||||||
Assert.assertEquals(CollUtil.newArrayList("type1", "type2", "type3"), types);
|
Assert.assertEquals(ListUtil.toList("type1", "type2", "type3"), types);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.clone.CloneSupport;
|
import cn.hutool.core.clone.CloneSupport;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -58,7 +58,7 @@ public class ObjectUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toStringTest() {
|
public void toStringTest() {
|
||||||
final ArrayList<String> strings = CollUtil.newArrayList("1", "2");
|
final ArrayList<String> strings = ListUtil.toList("1", "2");
|
||||||
final String result = ObjUtil.toString(strings);
|
final String result = ObjUtil.toString(strings);
|
||||||
Assert.assertEquals("[1, 2]", result);
|
Assert.assertEquals("[1, 2]", result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
@@ -15,13 +15,13 @@ public class RandomUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void randomEleSetTest(){
|
public void randomEleSetTest(){
|
||||||
final Set<Integer> set = RandomUtil.randomEleSet(CollUtil.newArrayList(1, 2, 3, 4, 5, 6), 2);
|
final Set<Integer> set = RandomUtil.randomEleSet(ListUtil.toList(1, 2, 3, 4, 5, 6), 2);
|
||||||
Assert.assertEquals(set.size(), 2);
|
Assert.assertEquals(set.size(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void randomElesTest(){
|
public void randomElesTest(){
|
||||||
final List<Integer> result = RandomUtil.randomEles(CollUtil.newArrayList(1, 2, 3, 4, 5, 6), 2);
|
final List<Integer> result = RandomUtil.randomEles(ListUtil.toList(1, 2, 3, 4, 5, 6), 2);
|
||||||
Assert.assertEquals(result.size(), 2);
|
Assert.assertEquals(result.size(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.regex.PatternPool;
|
import cn.hutool.core.regex.PatternPool;
|
||||||
import cn.hutool.core.regex.ReUtil;
|
import cn.hutool.core.regex.ReUtil;
|
||||||
@@ -82,7 +82,7 @@ public class ReUtilTest {
|
|||||||
public void findAllTest() {
|
public void findAllTest() {
|
||||||
// 查找所有匹配文本
|
// 查找所有匹配文本
|
||||||
final List<String> resultFindAll = ReUtil.findAll("\\w{2}", content, 0, new ArrayList<>());
|
final List<String> resultFindAll = ReUtil.findAll("\\w{2}", content, 0, new ArrayList<>());
|
||||||
final ArrayList<String> expected = CollUtil.newArrayList("ZZ", "Za", "aa", "bb", "bc", "cc", "12", "34");
|
final ArrayList<String> expected = ListUtil.toList("ZZ", "Za", "aa", "bb", "bc", "cc", "12", "34");
|
||||||
Assert.assertEquals(expected, resultFindAll);
|
Assert.assertEquals(expected, resultFindAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.io.resource.ResourceUtil;
|
import cn.hutool.core.io.resource.ResourceUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.map.MapBuilder;
|
import cn.hutool.core.map.MapBuilder;
|
||||||
@@ -109,7 +110,7 @@ public class XmlUtilTest {
|
|||||||
final Map<String, Object> map = XmlUtil.xmlToMap(xml);
|
final Map<String, Object> map = XmlUtil.xmlToMap(xml);
|
||||||
|
|
||||||
Assert.assertEquals(1, map.size());
|
Assert.assertEquals(1, map.size());
|
||||||
Assert.assertEquals(CollUtil.newArrayList("张三", "李四"), map.get("name"));
|
Assert.assertEquals(ListUtil.toList("张三", "李四"), map.get("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -137,7 +138,7 @@ public class XmlUtilTest {
|
|||||||
public void mapToXmlTest2() {
|
public void mapToXmlTest2() {
|
||||||
// 测试List
|
// 测试List
|
||||||
final Map<String, Object> map = MapBuilder.create(new LinkedHashMap<String, Object>())
|
final Map<String, Object> map = MapBuilder.create(new LinkedHashMap<String, Object>())
|
||||||
.put("Town", CollUtil.newArrayList("town1", "town2"))
|
.put("Town", ListUtil.toList("town1", "town2"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final Document doc = XmlUtil.mapToXml(map, "City");
|
final Document doc = XmlUtil.mapToXml(map, "City");
|
||||||
@@ -157,7 +158,7 @@ public class XmlUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readBySaxTest(){
|
public void readBySaxTest(){
|
||||||
final Set<String> eles = CollUtil.newHashSet(
|
final Set<String> eles = SetUtil.newHashSet(
|
||||||
"returnsms", "returnstatus", "message", "remainpoint", "taskID", "successCounts");
|
"returnsms", "returnstatus", "message", "remainpoint", "taskID", "successCounts");
|
||||||
XmlUtil.readBySax(ResourceUtil.getStream("test.xml"), new DefaultHandler(){
|
XmlUtil.readBySax(ResourceUtil.getStream("test.xml"), new DefaultHandler(){
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.db;
|
package cn.hutool.db;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.lang.func.Func1;
|
import cn.hutool.core.lang.func.Func1;
|
||||||
import cn.hutool.db.dialect.Dialect;
|
import cn.hutool.db.dialect.Dialect;
|
||||||
import cn.hutool.db.handler.BeanListHandler;
|
import cn.hutool.db.handler.BeanListHandler;
|
||||||
@@ -554,7 +554,7 @@ public abstract class AbstractDb<R extends AbstractDb<R>> extends DefaultConnect
|
|||||||
* @throws DbRuntimeException SQL执行异常
|
* @throws DbRuntimeException SQL执行异常
|
||||||
*/
|
*/
|
||||||
public <T> T find(final Entity where, final RsHandler<T> rsh, final String... fields) throws DbRuntimeException {
|
public <T> T find(final Entity where, final RsHandler<T> rsh, final String... fields) throws DbRuntimeException {
|
||||||
return find(CollUtil.newArrayList(fields), where, rsh);
|
return find(ListUtil.toList(fields), where, rsh);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.hutool.db;
|
package cn.hutool.db;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.lang.func.Func0;
|
import cn.hutool.core.lang.func.Func0;
|
||||||
import cn.hutool.core.map.Dict;
|
import cn.hutool.core.map.Dict;
|
||||||
import cn.hutool.core.reflect.MethodUtil;
|
import cn.hutool.core.reflect.MethodUtil;
|
||||||
@@ -155,7 +156,7 @@ public class Entity extends Dict {
|
|||||||
*/
|
*/
|
||||||
public Entity setFieldNames(final Collection<String> fieldNames) {
|
public Entity setFieldNames(final Collection<String> fieldNames) {
|
||||||
if (CollUtil.isNotEmpty(fieldNames)) {
|
if (CollUtil.isNotEmpty(fieldNames)) {
|
||||||
this.fieldNames = CollUtil.newHashSet(true, fieldNames);
|
this.fieldNames = SetUtil.newHashSet(true, fieldNames);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -168,7 +169,7 @@ public class Entity extends Dict {
|
|||||||
*/
|
*/
|
||||||
public Entity setFieldNames(final String... fieldNames) {
|
public Entity setFieldNames(final String... fieldNames) {
|
||||||
if (ArrayUtil.isNotEmpty(fieldNames)) {
|
if (ArrayUtil.isNotEmpty(fieldNames)) {
|
||||||
this.fieldNames = CollUtil.newLinkedHashSet(fieldNames);
|
this.fieldNames = SetUtil.newLinkedHashSet(fieldNames);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.db.sql;
|
package cn.hutool.db.sql;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.db.DbRuntimeException;
|
import cn.hutool.db.DbRuntimeException;
|
||||||
import cn.hutool.db.Entity;
|
import cn.hutool.db.Entity;
|
||||||
@@ -113,7 +113,7 @@ public class Query implements Cloneable {
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public Query setFields(final String... fields) {
|
public Query setFields(final String... fields) {
|
||||||
this.fields = CollUtil.newArrayList(fields);
|
this.fields = ListUtil.toList(fields);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.db;
|
package cn.hutool.db;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.db.handler.EntityListHandler;
|
import cn.hutool.db.handler.EntityListHandler;
|
||||||
@@ -107,7 +107,7 @@ public class CRUDTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findTest() {
|
public void findTest() {
|
||||||
final List<Entity> find = db.find(CollUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler());
|
final List<Entity> find = db.find(ListUtil.toList("name AS name2"), Entity.create("user"), new EntityListHandler());
|
||||||
Assert.assertFalse(find.isEmpty());
|
Assert.assertFalse(find.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ public class CRUDTest {
|
|||||||
Console.log(data1);
|
Console.log(data1);
|
||||||
Console.log(data2);
|
Console.log(data2);
|
||||||
|
|
||||||
final int[] result = db.insert(CollUtil.newArrayList(data1, data2));
|
final int[] result = db.insert(ListUtil.toList(data1, data2));
|
||||||
Console.log(result);
|
Console.log(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ public class CRUDTest {
|
|||||||
|
|
||||||
Console.log(data1);
|
Console.log(data1);
|
||||||
|
|
||||||
final int[] result = db.insert(CollUtil.newArrayList(data1));
|
final int[] result = db.insert(ListUtil.toList(data1));
|
||||||
Console.log(result);
|
Console.log(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.db;
|
package cn.hutool.db;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.db.handler.EntityListHandler;
|
import cn.hutool.db.handler.EntityListHandler;
|
||||||
@@ -31,7 +31,7 @@ public class ConcurentTest {
|
|||||||
for(int i = 0; i < 10000; i++) {
|
for(int i = 0; i < 10000; i++) {
|
||||||
ThreadUtil.execute(() -> {
|
ThreadUtil.execute(() -> {
|
||||||
final List<Entity> find;
|
final List<Entity> find;
|
||||||
find = db.find(CollUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler());
|
find = db.find(ListUtil.toList("name AS name2"), Entity.create("user"), new EntityListHandler());
|
||||||
Console.log(find);
|
Console.log(find);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.db.meta;
|
package cn.hutool.db.meta;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.SetUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
import cn.hutool.db.ds.DSFactory;
|
import cn.hutool.db.ds.DSFactory;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -27,7 +27,7 @@ public class MetaUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getTableMetaTest() {
|
public void getTableMetaTest() {
|
||||||
final Table table = MetaUtil.getTableMeta(ds, "user");
|
final Table table = MetaUtil.getTableMeta(ds, "user");
|
||||||
Assert.assertEquals(CollUtil.newHashSet("id"), table.getPkNames());
|
Assert.assertEquals(SetUtil.newHashSet("id"), table.getPkNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.hutool.extra.mail;
|
package cn.hutool.extra.mail;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.CharUtil;
|
import cn.hutool.core.util.CharUtil;
|
||||||
@@ -433,7 +434,7 @@ public class MailUtil {
|
|||||||
} else if (StrUtil.contains(addresses, ';')) {
|
} else if (StrUtil.contains(addresses, ';')) {
|
||||||
result = StrUtil.splitTrim(addresses, ';');
|
result = StrUtil.splitTrim(addresses, ';');
|
||||||
} else {
|
} else {
|
||||||
result = CollUtil.newArrayList(addresses);
|
result = ListUtil.toList(addresses);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.http.server.action;
|
package cn.hutool.http.server.action;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.http.server.HttpServerRequest;
|
import cn.hutool.http.server.HttpServerRequest;
|
||||||
import cn.hutool.http.server.HttpServerResponse;
|
import cn.hutool.http.server.HttpServerResponse;
|
||||||
@@ -58,7 +58,7 @@ public class RootAction implements Action {
|
|||||||
*/
|
*/
|
||||||
public RootAction(final File rootDir, final String... indexFileNames) {
|
public RootAction(final File rootDir, final String... indexFileNames) {
|
||||||
this.rootDir = rootDir;
|
this.rootDir = rootDir;
|
||||||
this.indexFileNames = CollUtil.toList(indexFileNames);
|
this.indexFileNames = ListUtil.toList(indexFileNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.http.useragent;
|
package cn.hutool.http.useragent;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.regex.ReUtil;
|
import cn.hutool.core.regex.ReUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -27,7 +27,7 @@ public class Browser extends UserAgentInfo {
|
|||||||
/**
|
/**
|
||||||
* 支持的浏览器类型
|
* 支持的浏览器类型
|
||||||
*/
|
*/
|
||||||
public static final List<Browser> browers = CollUtil.newArrayList(
|
public static final List<Browser> browers = ListUtil.toList(
|
||||||
// 部分特殊浏览器是基于安卓、Iphone等的,需要优先判断
|
// 部分特殊浏览器是基于安卓、Iphone等的,需要优先判断
|
||||||
// 企业微信 企业微信使用微信浏览器内核,会包含 MicroMessenger 所以要放在前面
|
// 企业微信 企业微信使用微信浏览器内核,会包含 MicroMessenger 所以要放在前面
|
||||||
new Browser("wxwork", "wxwork", "wxwork\\/([\\d\\w\\.\\-]+)"),
|
new Browser("wxwork", "wxwork", "wxwork\\/([\\d\\w\\.\\-]+)"),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.http.useragent;
|
package cn.hutool.http.useragent;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.regex.ReUtil;
|
import cn.hutool.core.regex.ReUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -21,7 +21,7 @@ public class Engine extends UserAgentInfo {
|
|||||||
/**
|
/**
|
||||||
* 支持的引擎类型
|
* 支持的引擎类型
|
||||||
*/
|
*/
|
||||||
public static final List<Engine> engines = CollUtil.newArrayList(
|
public static final List<Engine> engines = ListUtil.of(
|
||||||
new Engine("Trident", "trident"),
|
new Engine("Trident", "trident"),
|
||||||
new Engine("Webkit", "webkit"),
|
new Engine("Webkit", "webkit"),
|
||||||
new Engine("Chrome", "chrome"),
|
new Engine("Chrome", "chrome"),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.http.useragent;
|
package cn.hutool.http.useragent;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.regex.ReUtil;
|
import cn.hutool.core.regex.ReUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -23,7 +23,7 @@ public class OS extends UserAgentInfo {
|
|||||||
/**
|
/**
|
||||||
* 支持的引擎类型
|
* 支持的引擎类型
|
||||||
*/
|
*/
|
||||||
public static final List<OS> oses = CollUtil.newArrayList(//
|
public static final List<OS> oses = ListUtil.of(//
|
||||||
new OS("Windows 10 or Windows Server 2016", "windows nt 10\\.0", "windows nt (10\\.0)"),//
|
new OS("Windows 10 or Windows Server 2016", "windows nt 10\\.0", "windows nt (10\\.0)"),//
|
||||||
new OS("Windows 8.1 or Windows Server 2012R2", "windows nt 6\\.3", "windows nt (6\\.3)"),//
|
new OS("Windows 8.1 or Windows Server 2012R2", "windows nt 6\\.3", "windows nt (6\\.3)"),//
|
||||||
new OS("Windows 8 or Windows Server 2012", "windows nt 6\\.2", "windows nt (6\\.2)"),//
|
new OS("Windows 8 or Windows Server 2012", "windows nt 6\\.2", "windows nt (6\\.2)"),//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.http.useragent;
|
package cn.hutool.http.useragent;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -49,7 +49,7 @@ public class Platform extends UserAgentInfo {
|
|||||||
/**
|
/**
|
||||||
* 支持的移动平台类型
|
* 支持的移动平台类型
|
||||||
*/
|
*/
|
||||||
public static final List<Platform> mobilePlatforms = CollUtil.newArrayList(//
|
public static final List<Platform> mobilePlatforms = ListUtil.of(//
|
||||||
WINDOWS_PHONE, //
|
WINDOWS_PHONE, //
|
||||||
IPAD, //
|
IPAD, //
|
||||||
IPOD, //
|
IPOD, //
|
||||||
@@ -65,7 +65,7 @@ public class Platform extends UserAgentInfo {
|
|||||||
/**
|
/**
|
||||||
* 支持的桌面平台类型
|
* 支持的桌面平台类型
|
||||||
*/
|
*/
|
||||||
public static final List<Platform> desktopPlatforms = CollUtil.newArrayList(//
|
public static final List<Platform> desktopPlatforms = ListUtil.of(//
|
||||||
new Platform("Windows", "windows"), //
|
new Platform("Windows", "windows"), //
|
||||||
new Platform("Mac", "(macintosh|darwin)"), //
|
new Platform("Mac", "(macintosh|darwin)"), //
|
||||||
new Platform("Linux", "linux"), //
|
new Platform("Linux", "linux"), //
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.json;
|
package cn.hutool.json;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -19,7 +19,7 @@ public class IssueI1AU86Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toListTest() {
|
public void toListTest() {
|
||||||
final List<String> redisList = CollUtil.newArrayList(
|
final List<String> redisList = ListUtil.toList(
|
||||||
"{\"updateDate\":1583376342000,\"code\":\"move\",\"id\":1,\"sort\":1,\"name\":\"电影大全\"}",
|
"{\"updateDate\":1583376342000,\"code\":\"move\",\"id\":1,\"sort\":1,\"name\":\"电影大全\"}",
|
||||||
"{\"updateDate\":1583378882000,\"code\":\"zy\",\"id\":3,\"sort\":5,\"name\":\"综艺会\"}"
|
"{\"updateDate\":1583378882000,\"code\":\"zy\",\"id\":3,\"sort\":5,\"name\":\"综艺会\"}"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.hutool.json;
|
package cn.hutool.json;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.convert.ConvertException;
|
import cn.hutool.core.convert.ConvertException;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
@@ -98,7 +97,7 @@ public class JSONArrayTest {
|
|||||||
b2.setAkey("aValue2");
|
b2.setAkey("aValue2");
|
||||||
b2.setBkey("bValue2");
|
b2.setBkey("bValue2");
|
||||||
|
|
||||||
final ArrayList<KeyBean> list = CollUtil.newArrayList(b1, b2);
|
final ArrayList<KeyBean> list = ListUtil.toList(b1, b2);
|
||||||
|
|
||||||
final JSONArray jsonArray = JSONUtil.parseArray(list);
|
final JSONArray jsonArray = JSONUtil.parseArray(list);
|
||||||
Assert.assertEquals("aValue1", jsonArray.getJSONObject(0).getStr("akey"));
|
Assert.assertEquals("aValue1", jsonArray.getJSONObject(0).getStr("akey"));
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package cn.hutool.json;
|
|||||||
|
|
||||||
import cn.hutool.core.annotation.Alias;
|
import cn.hutool.core.annotation.Alias;
|
||||||
import cn.hutool.core.annotation.PropIgnore;
|
import cn.hutool.core.annotation.PropIgnore;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
@@ -238,7 +238,7 @@ public class JSONObjectTest {
|
|||||||
userA.setA("A user");
|
userA.setA("A user");
|
||||||
userA.setName("{\n\t\"body\":{\n\t\t\"loginId\":\"id\",\n\t\t\"password\":\"pwd\"\n\t}\n}");
|
userA.setName("{\n\t\"body\":{\n\t\t\"loginId\":\"id\",\n\t\t\"password\":\"pwd\"\n\t}\n}");
|
||||||
userA.setDate(new Date());
|
userA.setDate(new Date());
|
||||||
userA.setSqs(CollUtil.newArrayList(new Seq("seq1"), new Seq("seq2")));
|
userA.setSqs(ListUtil.toList(new Seq("seq1"), new Seq("seq2")));
|
||||||
|
|
||||||
final JSONObject json = JSONUtil.parseObj(userA);
|
final JSONObject json = JSONUtil.parseObj(userA);
|
||||||
final UserA userA2 = json.toBean(UserA.class);
|
final UserA userA2 = json.toBean(UserA.class);
|
||||||
@@ -320,7 +320,7 @@ public class JSONObjectTest {
|
|||||||
final UserA userA = new UserA();
|
final UserA userA = new UserA();
|
||||||
userA.setName("nameTest");
|
userA.setName("nameTest");
|
||||||
userA.setDate(new Date());
|
userA.setDate(new Date());
|
||||||
userA.setSqs(CollUtil.newArrayList(new Seq(null), new Seq("seq2")));
|
userA.setSqs(ListUtil.toList(new Seq(null), new Seq("seq2")));
|
||||||
|
|
||||||
final JSONObject json = JSONUtil.parseObj(userA, false);
|
final JSONObject json = JSONUtil.parseObj(userA, false);
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ public class JSONObjectTest {
|
|||||||
final TestBean bean = new TestBean();
|
final TestBean bean = new TestBean();
|
||||||
bean.setDoubleValue(111.1);
|
bean.setDoubleValue(111.1);
|
||||||
bean.setIntValue(123);
|
bean.setIntValue(123);
|
||||||
bean.setList(CollUtil.newArrayList("a", "b", "c"));
|
bean.setList(ListUtil.toList("a", "b", "c"));
|
||||||
bean.setStrValue("strTest");
|
bean.setStrValue("strTest");
|
||||||
bean.setTestEnum(TestEnum.TYPE_B);
|
bean.setTestEnum(TestEnum.TYPE_B);
|
||||||
|
|
||||||
@@ -565,7 +565,7 @@ public class JSONObjectTest {
|
|||||||
*
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeStatic"})
|
||||||
public static class SameNameBean {
|
public static class SameNameBean {
|
||||||
private final String username = "123";
|
private final String username = "123";
|
||||||
private final String userName = "abc";
|
private final String userName = "abc";
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.hutool.json;
|
package cn.hutool.json;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
@@ -59,7 +58,7 @@ public class JSONUtilTest {
|
|||||||
a2.setDate(DateUtil.date());
|
a2.setDate(DateUtil.date());
|
||||||
a2.setName("AAAA222Name");
|
a2.setName("AAAA222Name");
|
||||||
|
|
||||||
final ArrayList<UserA> list = CollUtil.newArrayList(a1, a2);
|
final ArrayList<UserA> list = ListUtil.toList(a1, a2);
|
||||||
final HashMap<String, Object> map = MapUtil.newHashMap();
|
final HashMap<String, Object> map = MapUtil.newHashMap();
|
||||||
map.put("total", 13);
|
map.put("total", 13);
|
||||||
map.put("rows", list);
|
map.put("rows", list);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.json;
|
package cn.hutool.json;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -24,12 +24,12 @@ public class ParseBeanTest {
|
|||||||
c2.setTest("test2");
|
c2.setTest("test2");
|
||||||
|
|
||||||
final B b1 = new B();
|
final B b1 = new B();
|
||||||
b1.setCs(CollUtil.newArrayList(c1, c2));
|
b1.setCs(ListUtil.toList(c1, c2));
|
||||||
final B b2 = new B();
|
final B b2 = new B();
|
||||||
b2.setCs(CollUtil.newArrayList(c1, c2));
|
b2.setCs(ListUtil.toList(c1, c2));
|
||||||
|
|
||||||
final A a = new A();
|
final A a = new A();
|
||||||
a.setBs(CollUtil.newArrayList(b1, b2));
|
a.setBs(ListUtil.toList(b1, b2));
|
||||||
|
|
||||||
final JSONObject json = JSONUtil.parseObj(a);
|
final JSONObject json = JSONUtil.parseObj(a);
|
||||||
final A a1 = JSONUtil.toBean(json, A.class);
|
final A a1 = JSONUtil.toBean(json, A.class);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.hutool.poi.excel;
|
package cn.hutool.poi.excel;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.comparator.IndexedComparator;
|
import cn.hutool.core.comparator.IndexedComparator;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
@@ -13,8 +13,8 @@ import cn.hutool.core.map.TableMap;
|
|||||||
import cn.hutool.core.map.multi.RowKeyTable;
|
import cn.hutool.core.map.multi.RowKeyTable;
|
||||||
import cn.hutool.core.map.multi.Table;
|
import cn.hutool.core.map.multi.Table;
|
||||||
import cn.hutool.core.net.URLEncoder;
|
import cn.hutool.core.net.URLEncoder;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.poi.excel.cell.CellLocation;
|
import cn.hutool.poi.excel.cell.CellLocation;
|
||||||
import cn.hutool.poi.excel.cell.CellUtil;
|
import cn.hutool.poi.excel.cell.CellUtil;
|
||||||
import cn.hutool.poi.excel.style.Align;
|
import cn.hutool.poi.excel.style.Align;
|
||||||
@@ -1017,7 +1017,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
|||||||
}
|
}
|
||||||
} else if (rowBean instanceof Hyperlink) {
|
} else if (rowBean instanceof Hyperlink) {
|
||||||
// Hyperlink当成一个值
|
// Hyperlink当成一个值
|
||||||
return writeRow(CollUtil.newArrayList(rowBean), isWriteKeyAsHead);
|
return writeRow(ListUtil.toList(rowBean), isWriteKeyAsHead);
|
||||||
} else if (BeanUtil.isBean(rowBean.getClass())) {
|
} else if (BeanUtil.isBean(rowBean.getClass())) {
|
||||||
if (MapUtil.isEmpty(this.headerAlias)) {
|
if (MapUtil.isEmpty(this.headerAlias)) {
|
||||||
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<>(), false, false);
|
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<>(), false, false);
|
||||||
@@ -1027,7 +1027,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 其它转为字符串默认输出
|
// 其它转为字符串默认输出
|
||||||
return writeRow(CollUtil.newArrayList(rowBean), isWriteKeyAsHead);
|
return writeRow(ListUtil.toList(rowBean), isWriteKeyAsHead);
|
||||||
}
|
}
|
||||||
return writeRow(rowMap, isWriteKeyAsHead);
|
return writeRow(rowMap, isWriteKeyAsHead);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.hutool.poi.word;
|
package cn.hutool.poi.word;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.collection.iter.IterUtil;
|
import cn.hutool.core.collection.iter.IterUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
@@ -94,7 +94,7 @@ public class TableUtil {
|
|||||||
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<>(), false, false);
|
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<>(), false, false);
|
||||||
} else {
|
} else {
|
||||||
// 其它转为字符串默认输出
|
// 其它转为字符串默认输出
|
||||||
writeRow(row, CollUtil.newArrayList(rowBean), isWriteKeyAsHead);
|
writeRow(row, ListUtil.toList(rowBean), isWriteKeyAsHead);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.poi.excel;
|
package cn.hutool.poi.excel;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
@@ -30,7 +30,7 @@ public class BigExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void writeTest2() {
|
public void writeTest2() {
|
||||||
final List<String> row = CollUtil.newArrayList("姓名", "加班日期", "下班时间", "加班时长", "餐补", "车补次数", "车补", "总计");
|
final List<String> row = ListUtil.toList("姓名", "加班日期", "下班时间", "加班时长", "餐补", "车补次数", "车补", "总计");
|
||||||
final BigExcelWriter overtimeWriter = ExcelUtil.getBigWriter("e:/excel/single_line.xlsx");
|
final BigExcelWriter overtimeWriter = ExcelUtil.getBigWriter("e:/excel/single_line.xlsx");
|
||||||
overtimeWriter.write(row);
|
overtimeWriter.write(row);
|
||||||
overtimeWriter.close();
|
overtimeWriter.close();
|
||||||
@@ -39,13 +39,13 @@ public class BigExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void writeTest() {
|
public void writeTest() {
|
||||||
final List<?> row1 = CollUtil.newArrayList("aaaaa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
final List<?> row1 = ListUtil.toList("aaaaa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
||||||
final List<?> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
final List<?> row2 = ListUtil.toList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
||||||
final List<?> row3 = CollUtil.newArrayList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
final List<?> row3 = ListUtil.toList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
||||||
final List<?> row4 = CollUtil.newArrayList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
final List<?> row4 = ListUtil.toList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
||||||
final List<?> row5 = CollUtil.newArrayList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
final List<?> row5 = ListUtil.toList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
||||||
|
|
||||||
final List<List<?>> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5);
|
final List<List<?>> rows = ListUtil.toList(row1, row2, row3, row4, row5);
|
||||||
for(int i=0; i < 400000; i++) {
|
for(int i=0; i < 400000; i++) {
|
||||||
//超大列表写出测试
|
//超大列表写出测试
|
||||||
rows.add(ObjUtil.clone(row1));
|
rows.add(ObjUtil.clone(row1));
|
||||||
@@ -70,13 +70,13 @@ public class BigExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void mergeTest() {
|
public void mergeTest() {
|
||||||
final List<?> row1 = CollUtil.newArrayList("aa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
final List<?> row1 = ListUtil.toList("aa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
||||||
final List<?> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
final List<?> row2 = ListUtil.toList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
||||||
final List<?> row3 = CollUtil.newArrayList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
final List<?> row3 = ListUtil.toList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
||||||
final List<?> row4 = CollUtil.newArrayList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
final List<?> row4 = ListUtil.toList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
||||||
final List<?> row5 = CollUtil.newArrayList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
final List<?> row5 = ListUtil.toList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
||||||
|
|
||||||
final List<List<?>> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5);
|
final List<List<?>> rows = ListUtil.toList(row1, row2, row3, row4, row5);
|
||||||
|
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final BigExcelWriter writer = ExcelUtil.getBigWriter("e:/mergeTest.xlsx");
|
final BigExcelWriter writer = ExcelUtil.getBigWriter("e:/mergeTest.xlsx");
|
||||||
@@ -114,7 +114,7 @@ public class BigExcelWriteTest {
|
|||||||
row2.put("是否合格", false);
|
row2.put("是否合格", false);
|
||||||
row2.put("考试日期", DateUtil.date());
|
row2.put("考试日期", DateUtil.date());
|
||||||
|
|
||||||
final ArrayList<Map<String, Object>> rows = CollUtil.newArrayList(row1, row2);
|
final ArrayList<Map<String, Object>> rows = ListUtil.toList(row1, row2);
|
||||||
|
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final String path = "e:/bigWriteMapTest.xlsx";
|
final String path = "e:/bigWriteMapTest.xlsx";
|
||||||
@@ -174,7 +174,7 @@ public class BigExcelWriteTest {
|
|||||||
bean2.setScore(38.50);
|
bean2.setScore(38.50);
|
||||||
bean2.setExamDate(DateUtil.date());
|
bean2.setExamDate(DateUtil.date());
|
||||||
|
|
||||||
final List<cn.hutool.poi.excel.TestBean> rows = CollUtil.newArrayList(bean1, bean2);
|
final List<cn.hutool.poi.excel.TestBean> rows = ListUtil.toList(bean1, bean2);
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final String file = "e:/bigWriteBeanTest.xlsx";
|
final String file = "e:/bigWriteBeanTest.xlsx";
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package cn.hutool.poi.excel;
|
package cn.hutool.poi.excel;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
|
import cn.hutool.core.lang.id.IdUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.lang.id.IdUtil;
|
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.poi.excel.cell.setters.EscapeStrCellSetter;
|
import cn.hutool.poi.excel.cell.setters.EscapeStrCellSetter;
|
||||||
import cn.hutool.poi.excel.style.StyleUtil;
|
import cn.hutool.poi.excel.style.StyleUtil;
|
||||||
@@ -47,12 +46,12 @@ public class ExcelWriteTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void writeNoFlushTest(){
|
public void writeNoFlushTest(){
|
||||||
final List<?> row1 = CollUtil.newArrayList("aaaaa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
final List<?> row1 = ListUtil.toList("aaaaa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
||||||
final List<?> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
final List<?> row2 = ListUtil.toList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
||||||
final List<?> row3 = CollUtil.newArrayList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
final List<?> row3 = ListUtil.toList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
||||||
final List<?> row4 = CollUtil.newArrayList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
final List<?> row4 = ListUtil.toList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
||||||
final List<?> row5 = CollUtil.newArrayList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
final List<?> row5 = ListUtil.toList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
||||||
final List<List<?>> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5);
|
final List<List<?>> rows = ListUtil.toList(row1, row2, row3, row4, row5);
|
||||||
|
|
||||||
final ExcelWriter writer = ExcelUtil.getWriter();
|
final ExcelWriter writer = ExcelUtil.getWriter();
|
||||||
writer.write(rows);
|
writer.write(rows);
|
||||||
@@ -62,13 +61,13 @@ public class ExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void testRowOrColumnCellStyle() {
|
public void testRowOrColumnCellStyle() {
|
||||||
final List<?> row1 = CollUtil.newArrayList("aaaaa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
final List<?> row1 = ListUtil.toList("aaaaa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
||||||
final List<?> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
final List<?> row2 = ListUtil.toList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
||||||
final List<?> row3 = CollUtil.newArrayList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
final List<?> row3 = ListUtil.toList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
||||||
final List<?> row4 = CollUtil.newArrayList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
final List<?> row4 = ListUtil.toList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
||||||
final List<?> row5 = CollUtil.newArrayList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
final List<?> row5 = ListUtil.toList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
||||||
|
|
||||||
final List<List<?>> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5);
|
final List<List<?>> rows = ListUtil.toList(row1, row2, row3, row4, row5);
|
||||||
final BigExcelWriter overtimeWriter = ExcelUtil.getBigWriter("d:/test/style_line.xlsx");
|
final BigExcelWriter overtimeWriter = ExcelUtil.getBigWriter("d:/test/style_line.xlsx");
|
||||||
|
|
||||||
overtimeWriter.write(rows, true);
|
overtimeWriter.write(rows, true);
|
||||||
@@ -106,7 +105,7 @@ public class ExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void writeTest2() {
|
public void writeTest2() {
|
||||||
final List<String> row = CollUtil.newArrayList("姓名", "加班日期", "下班时间", "加班时长", "餐补", "车补次数", "车补", "总计");
|
final List<String> row = ListUtil.toList("姓名", "加班日期", "下班时间", "加班时长", "餐补", "车补次数", "车补", "总计");
|
||||||
final ExcelWriter overtimeWriter = ExcelUtil.getWriter("e:/excel/single_line.xlsx");
|
final ExcelWriter overtimeWriter = ExcelUtil.getWriter("e:/excel/single_line.xlsx");
|
||||||
overtimeWriter.writeRow(row);
|
overtimeWriter.writeRow(row);
|
||||||
overtimeWriter.close();
|
overtimeWriter.close();
|
||||||
@@ -118,12 +117,12 @@ public class ExcelWriteTest {
|
|||||||
final ExcelWriter writer = ExcelUtil.getWriterWithSheet("表格1");
|
final ExcelWriter writer = ExcelUtil.getWriterWithSheet("表格1");
|
||||||
|
|
||||||
// 写出第一张表
|
// 写出第一张表
|
||||||
final List<String> row = CollUtil.newArrayList("姓名", "加班日期", "下班时间", "加班时长", "餐补", "车补次数", "车补", "总计");
|
final List<String> row = ListUtil.toList("姓名", "加班日期", "下班时间", "加班时长", "餐补", "车补次数", "车补", "总计");
|
||||||
writer.writeRow(row);
|
writer.writeRow(row);
|
||||||
|
|
||||||
// 写出第二张表
|
// 写出第二张表
|
||||||
writer.setSheet("表格2");
|
writer.setSheet("表格2");
|
||||||
final List<String> row2 = CollUtil.newArrayList("姓名2", "加班日期2", "下班时间2", "加班时长2", "餐补2", "车补次数2", "车补2", "总计2");
|
final List<String> row2 = ListUtil.toList("姓名2", "加班日期2", "下班时间2", "加班时长2", "餐补2", "车补次数2", "车补2", "总计2");
|
||||||
writer.writeRow(row2);
|
writer.writeRow(row2);
|
||||||
|
|
||||||
// 生成文件或导出Excel
|
// 生成文件或导出Excel
|
||||||
@@ -135,13 +134,13 @@ public class ExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void writeTest() {
|
public void writeTest() {
|
||||||
final List<?> row1 = CollUtil.newArrayList("aaaaa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
final List<?> row1 = ListUtil.toList("aaaaa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
||||||
final List<?> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
final List<?> row2 = ListUtil.toList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
||||||
final List<?> row3 = CollUtil.newArrayList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
final List<?> row3 = ListUtil.toList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
||||||
final List<?> row4 = CollUtil.newArrayList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
final List<?> row4 = ListUtil.toList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
||||||
final List<?> row5 = CollUtil.newArrayList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
final List<?> row5 = ListUtil.toList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
||||||
|
|
||||||
final List<List<?>> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5);
|
final List<List<?>> rows = ListUtil.toList(row1, row2, row3, row4, row5);
|
||||||
for (int i = 0; i < 400; i++) {
|
for (int i = 0; i < 400; i++) {
|
||||||
// 超大列表写出测试
|
// 超大列表写出测试
|
||||||
rows.add(ObjUtil.clone(row1));
|
rows.add(ObjUtil.clone(row1));
|
||||||
@@ -170,13 +169,13 @@ public class ExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void mergeTest() {
|
public void mergeTest() {
|
||||||
final List<?> row1 = CollUtil.newArrayList("aa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
final List<?> row1 = ListUtil.toList("aa", "bb", "cc", "dd", DateUtil.date(), 3.22676575765);
|
||||||
final List<?> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
final List<?> row2 = ListUtil.toList("aa1", "bb1", "cc1", "dd1", DateUtil.date(), 250.7676);
|
||||||
final List<?> row3 = CollUtil.newArrayList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
final List<?> row3 = ListUtil.toList("aa2", "bb2", "cc2", "dd2", DateUtil.date(), 0.111);
|
||||||
final List<?> row4 = CollUtil.newArrayList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
final List<?> row4 = ListUtil.toList("aa3", "bb3", "cc3", "dd3", DateUtil.date(), 35);
|
||||||
final List<?> row5 = CollUtil.newArrayList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
final List<?> row5 = ListUtil.toList("aa4", "bb4", "cc4", "dd4", DateUtil.date(), 28.00);
|
||||||
|
|
||||||
final List<List<?>> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5);
|
final List<List<?>> rows = ListUtil.toList(row1, row2, row3, row4, row5);
|
||||||
|
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/mergeTest.xlsx");
|
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/mergeTest.xlsx");
|
||||||
@@ -214,7 +213,7 @@ public class ExcelWriteTest {
|
|||||||
row2.put("是否合格", false);
|
row2.put("是否合格", false);
|
||||||
row2.put("考试日期", DateUtil.date());
|
row2.put("考试日期", DateUtil.date());
|
||||||
|
|
||||||
final ArrayList<Map<String, Object>> rows = CollUtil.newArrayList(row1, row2);
|
final ArrayList<Map<String, Object>> rows = ListUtil.toList(row1, row2);
|
||||||
|
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/writeMapTest.xlsx");
|
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/writeMapTest.xlsx");
|
||||||
@@ -244,7 +243,7 @@ public class ExcelWriteTest {
|
|||||||
row2.put("是否合格", false);
|
row2.put("是否合格", false);
|
||||||
row2.put("考试日期", DateUtil.date());
|
row2.put("考试日期", DateUtil.date());
|
||||||
|
|
||||||
final ArrayList<Map<String, Object>> rows = CollUtil.newArrayList(row1, row2);
|
final ArrayList<Map<String, Object>> rows = ListUtil.toList(row1, row2);
|
||||||
|
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final ExcelWriter writer = ExcelUtil.getWriter("e:/excel/writeMapTest.xlsx");
|
final ExcelWriter writer = ExcelUtil.getWriter("e:/excel/writeMapTest.xlsx");
|
||||||
@@ -326,7 +325,7 @@ public class ExcelWriteTest {
|
|||||||
row2.put("score", 32.30);
|
row2.put("score", 32.30);
|
||||||
row2.put("examDate", DateUtil.date());
|
row2.put("examDate", DateUtil.date());
|
||||||
|
|
||||||
final List<Map<Object, Object>> rows = CollUtil.newArrayList(row1, row2);
|
final List<Map<Object, Object>> rows = ListUtil.toList(row1, row2);
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final String file = "d:/test/writeMapAlias.xlsx";
|
final String file = "d:/test/writeMapAlias.xlsx";
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
@@ -361,7 +360,7 @@ public class ExcelWriteTest {
|
|||||||
row2.put("score", 32.30);
|
row2.put("score", 32.30);
|
||||||
row2.put("examDate", DateUtil.date());
|
row2.put("examDate", DateUtil.date());
|
||||||
|
|
||||||
final List<Map<Object, Object>> rows = CollUtil.newArrayList(row1, row2);
|
final List<Map<Object, Object>> rows = ListUtil.toList(row1, row2);
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final String file = "f:/test/test_alias.xlsx";
|
final String file = "f:/test/test_alias.xlsx";
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
@@ -394,7 +393,7 @@ public class ExcelWriteTest {
|
|||||||
row2.put("score", 32.30);
|
row2.put("score", 32.30);
|
||||||
row2.put("examDate", DateUtil.date());
|
row2.put("examDate", DateUtil.date());
|
||||||
|
|
||||||
final List<Map<Object, Object>> rows = CollUtil.newArrayList(row1, row2);
|
final List<Map<Object, Object>> rows = ListUtil.toList(row1, row2);
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final String file = "d:/test/test_alias.xls";
|
final String file = "d:/test/test_alias.xls";
|
||||||
final ExcelWriter writer = ExcelUtil.getWriter(file, "test1");
|
final ExcelWriter writer = ExcelUtil.getWriter(file, "test1");
|
||||||
@@ -425,7 +424,7 @@ public class ExcelWriteTest {
|
|||||||
row2.put("score", 32.30);
|
row2.put("score", 32.30);
|
||||||
row2.put("examDate", DateUtil.date());
|
row2.put("examDate", DateUtil.date());
|
||||||
|
|
||||||
final List<Map<Object, Object>> rows = CollUtil.newArrayList(row1, row2);
|
final List<Map<Object, Object>> rows = ListUtil.toList(row1, row2);
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final String file = "d:/test/test_alias.xls";
|
final String file = "d:/test/test_alias.xls";
|
||||||
final ExcelWriter writer = ExcelUtil.getWriter(file, "test1");
|
final ExcelWriter writer = ExcelUtil.getWriter(file, "test1");
|
||||||
@@ -459,7 +458,7 @@ public class ExcelWriteTest {
|
|||||||
bean2.setScore(38.50);
|
bean2.setScore(38.50);
|
||||||
bean2.setExamDate(DateUtil.date());
|
bean2.setExamDate(DateUtil.date());
|
||||||
|
|
||||||
final List<cn.hutool.poi.excel.TestBean> rows = CollUtil.newArrayList(bean1, bean2);
|
final List<cn.hutool.poi.excel.TestBean> rows = ListUtil.toList(bean1, bean2);
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final String file = "e:/writeBeanTest.xlsx";
|
final String file = "e:/writeBeanTest.xlsx";
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
@@ -491,7 +490,7 @@ public class ExcelWriteTest {
|
|||||||
order1.setNum("456");
|
order1.setNum("456");
|
||||||
order1.setBody("body2");
|
order1.setBody("body2");
|
||||||
|
|
||||||
final List<cn.hutool.poi.excel.OrderExcel> rows = CollUtil.newArrayList(order1, order2);
|
final List<cn.hutool.poi.excel.OrderExcel> rows = ListUtil.toList(order1, order2);
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final String file = "f:/test/writeBeanTest2.xlsx";
|
final String file = "f:/test/writeBeanTest2.xlsx";
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
@@ -518,7 +517,7 @@ public class ExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void addSelectTest() {
|
public void addSelectTest() {
|
||||||
final List<String> row = CollUtil.newArrayList("姓名", "加班日期", "下班时间", "加班时长", "餐补", "车补次数", "车补", "总计");
|
final List<String> row = ListUtil.toList("姓名", "加班日期", "下班时间", "加班时长", "餐补", "车补次数", "车补", "总计");
|
||||||
final ExcelWriter overtimeWriter = ExcelUtil.getWriter("d:/test/single_line.xlsx");
|
final ExcelWriter overtimeWriter = ExcelUtil.getWriter("d:/test/single_line.xlsx");
|
||||||
overtimeWriter.writeCellValue(3, 4, "AAAA");
|
overtimeWriter.writeCellValue(3, 4, "AAAA");
|
||||||
overtimeWriter.addSelect(3, 4, row.toArray(new String[0]));
|
overtimeWriter.addSelect(3, 4, row.toArray(new String[0]));
|
||||||
@@ -684,13 +683,13 @@ public class ExcelWriteTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void writeSecHeadRowTest() {
|
public void writeSecHeadRowTest() {
|
||||||
final List<?> row1 = CollUtil.newArrayList(1, "aa", "bb", "cc", "dd", "ee");
|
final List<?> row1 = ListUtil.toList(1, "aa", "bb", "cc", "dd", "ee");
|
||||||
final List<?> row2 = CollUtil.newArrayList(2, "aa1", "bb1", "cc1", "dd1", "ee1");
|
final List<?> row2 = ListUtil.toList(2, "aa1", "bb1", "cc1", "dd1", "ee1");
|
||||||
final List<?> row3 = CollUtil.newArrayList(3, "aa2", "bb2", "cc2", "dd2", "ee2");
|
final List<?> row3 = ListUtil.toList(3, "aa2", "bb2", "cc2", "dd2", "ee2");
|
||||||
final List<?> row4 = CollUtil.newArrayList(4, "aa3", "bb3", "cc3", "dd3", "ee3");
|
final List<?> row4 = ListUtil.toList(4, "aa3", "bb3", "cc3", "dd3", "ee3");
|
||||||
final List<?> row5 = CollUtil.newArrayList(5, "aa4", "bb4", "cc4", "dd4", "ee4");
|
final List<?> row5 = ListUtil.toList(5, "aa4", "bb4", "cc4", "dd4", "ee4");
|
||||||
|
|
||||||
final List<List<?>> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5);
|
final List<List<?>> rows = ListUtil.toList(row1, row2, row3, row4, row5);
|
||||||
|
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/writeSecHeadRowTest.xlsx");
|
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/writeSecHeadRowTest.xlsx");
|
||||||
@@ -719,7 +718,7 @@ public class ExcelWriteTest {
|
|||||||
writer.merge(2, 2, 4, 5, "DDEE", true);
|
writer.merge(2, 2, 4, 5, "DDEE", true);
|
||||||
writer.setCurrentRow(3);
|
writer.setCurrentRow(3);
|
||||||
|
|
||||||
final List<String> sechead = CollUtil.newArrayList("AA", "BB", "DD", "EE");
|
final List<String> sechead = ListUtil.toList("AA", "BB", "DD", "EE");
|
||||||
writer.writeSecHeadRow(sechead);
|
writer.writeSecHeadRow(sechead);
|
||||||
// 一次性写出内容,使用默认样式
|
// 一次性写出内容,使用默认样式
|
||||||
writer.write(rows);
|
writer.write(rows);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.hutool.poi.word;
|
package cn.hutool.poi.word;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
@@ -49,7 +48,7 @@ public class WordWriterTest {
|
|||||||
map.put("成绩", 88.32);
|
map.put("成绩", 88.32);
|
||||||
map.put("是否合格", true);
|
map.put("是否合格", true);
|
||||||
|
|
||||||
writer.addTable(CollUtil.newArrayList(map));
|
writer.addTable(ListUtil.toList(map));
|
||||||
writer.flush(FileUtil.file("d:/test/test.docx"));
|
writer.flush(FileUtil.file("d:/test/test.docx"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +71,7 @@ public class WordWriterTest {
|
|||||||
data2.put("是否合格", false);
|
data2.put("是否合格", false);
|
||||||
data2.put("考试日期", DateUtil.date());
|
data2.put("考试日期", DateUtil.date());
|
||||||
|
|
||||||
final ArrayList<Map<String, Object>> mapArrayList = CollUtil.newArrayList(data, data2);
|
final ArrayList<Map<String, Object>> mapArrayList = ListUtil.toList(data, data2);
|
||||||
|
|
||||||
// 添加段落(标题)
|
// 添加段落(标题)
|
||||||
writer.addText(new Font("方正小标宋简体", Font.PLAIN, 22), "我是第一部分");
|
writer.addText(new Font("方正小标宋简体", Font.PLAIN, 22), "我是第一部分");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.setting;
|
package cn.hutool.setting;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
@@ -13,9 +13,9 @@ import cn.hutool.core.io.watch.SimpleWatcher;
|
|||||||
import cn.hutool.core.io.watch.WatchMonitor;
|
import cn.hutool.core.io.watch.WatchMonitor;
|
||||||
import cn.hutool.core.io.watch.WatchUtil;
|
import cn.hutool.core.io.watch.WatchUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.text.StrUtil;
|
||||||
import cn.hutool.core.util.CharUtil;
|
import cn.hutool.core.util.CharUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
|
||||||
import cn.hutool.log.StaticLog;
|
import cn.hutool.log.StaticLog;
|
||||||
import cn.hutool.setting.dialect.Props;
|
import cn.hutool.setting.dialect.Props;
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
|||||||
* @return 获得所有分组名
|
* @return 获得所有分组名
|
||||||
*/
|
*/
|
||||||
public List<String> getGroups() {
|
public List<String> getGroups() {
|
||||||
return CollUtil.newArrayList(this.groupedMap.keySet());
|
return ListUtil.toList(this.groupedMap.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user