com.tukeof.common.util.collection.CollectionUnionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-core Show documentation
Show all versions of common-core Show documentation
a common and useful pure java library
The newest version!
package com.tukeof.common.util.collection;
import com.tukeof.common.annotation.NotNull;
import com.tukeof.common.annotation.Nullable;
import com.tukeof.common.util.ReflectUtil;
import com.tukeof.common.util.bean.BeanStringUtil;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
/**
* Create by tuke on 2019-02-14
*/
public class CollectionUnionUtil {
// keyRowGetter
// ReflectUtil::getFirstFieldValue
// keyColumnFormatter
// (K key) -> Collections.singletonList(key.toString())
// blockColumnFormatter
// (T bean) -> BeanStringUtil.toStringList(bean, excludeAnnotations)
public static List> unionVertical(
@Nullable Class extends Annotation>[] excludeAnnotations,
int blockWidth,
@NotNull List[] blocks) {
return unionVertical(
ReflectUtil::getFirstFieldValue,
excludeAnnotations,
blockWidth,
blocks);
}
// keyColumnFormatter
// (K key) -> Collections.singletonList(key.toString())
// blockColumnFormatter
// (T bean) -> BeanStringUtil.toStringList(bean, excludeAnnotations)
public static List> unionVertical(
@NotNull Function keyRowGetter,
@Nullable Class extends Annotation>[] excludeAnnotations,
int blockWidth,
@NotNull List[] blocks) {
return unionVertical(
keyRowGetter,
(K key) -> Collections.singletonList(key.toString()),
excludeAnnotations,
blockWidth,
blocks);
}
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// blockColumnFormatter
// (T bean) -> BeanStringUtil.toStringList(bean, excludeAnnotations)
public static List> unionVertical(
@NotNull Function keyRowGetter,
@NotNull Function> keyColumnFormatter,
@Nullable Class extends Annotation>[] excludeAnnotations,
int blockWidth,
@NotNull List[] blocks) {
return BasicCollectionUnionUtil.unionVertical(
keyRowGetter,
keyColumnFormatter,
(T bean) -> BeanStringUtil.toStringList(bean, excludeAnnotations),
blockWidth,
blocks);
}
// keyColumnFormatter
// (K key) -> Collections.singletonList(key.toString())
public static List> unionVertical(
@NotNull Function keyRowGetter,
@NotNull Function> blockColumnFormatter,
int blockWidth,
@NotNull List[] blocks) {
return BasicCollectionUnionUtil.unionVertical(
keyRowGetter,
(K key) -> Collections.singletonList(key.toString()),
blockColumnFormatter,
blockWidth,
blocks);
}
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// keyColumnFormatter
// (K key) -> Collections.singletonList(key.toString())
public static List> unionVertical(
@NotNull Function