public interface TreeSupportEntity<PK> extends Entity
| 限定符和类型 | 接口和说明 |
|---|---|
static interface |
TreeSupportEntity.TreeHelper<T,PK>
树结构Helper
|
| 限定符和类型 | 方法和说明 |
|---|---|
static <T extends TreeSupportEntity<PK>,PK> |
expandTree2List(T parent,
IDGenerator<PK> idGenerator) |
static <T extends TreeSupportEntity<PK>,PK> |
expandTree2List(T parent,
List<T> target,
IDGenerator<PK> idGenerator) |
static <T extends TreeSupportEntity<PK>,PK> |
expandTree2List(T root,
List<T> target,
IDGenerator<PK> idGenerator,
java.util.function.BiConsumer<T,List<T>> childConsumer)
将树形结构转为列表结构,并填充对应的数据。
|
static <T extends TreeSupportEntity> |
forEach(Collection<T> list,
java.util.function.Consumer<T> consumer) |
<T extends TreeSupportEntity<PK>> |
getChildren() |
PK |
getId() |
Integer |
getLevel() |
PK |
getParentId() |
static String |
getParentPath(String path)
根据path获取父节点的path
|
String |
getPath() |
static <N extends TreeSupportEntity<PK>,PK> |
list2tree(Collection<N> dataList,
java.util.function.BiConsumer<N,List<N>> childConsumer)
集合转为树形结构,返回根节点集合
|
static <N extends TreeSupportEntity<PK>,PK> |
list2tree(Collection<N> dataList,
java.util.function.BiConsumer<N,List<N>> childConsumer,
java.util.function.Function<TreeSupportEntity.TreeHelper<N,PK>,java.util.function.Predicate<N>> predicateFunction)
列表结构转为树结构,并返回根节点集合
|
static <N extends TreeSupportEntity<PK>,PK> |
list2tree(Collection<N> dataList,
java.util.function.BiConsumer<N,List<N>> childConsumer,
java.util.function.Predicate<N> rootNodePredicate) |
void |
setId(PK id) |
void |
setLevel(Integer level) |
void |
setParentId(PK parentId) |
void |
setPath(String path) |
copyFrom, copyTo, tryValidatePK getId()
void setId(PK id)
String getPath()
void setPath(String path)
PK getParentId()
void setParentId(PK parentId)
Integer getLevel()
void setLevel(Integer level)
<T extends TreeSupportEntity<PK>> List<T> getChildren()
static <T extends TreeSupportEntity> void forEach(Collection<T> list, java.util.function.Consumer<T> consumer)
static <T extends TreeSupportEntity<PK>,PK> List<T> expandTree2List(T parent, IDGenerator<PK> idGenerator)
static <T extends TreeSupportEntity<PK>,PK> void expandTree2List(T parent, List<T> target, IDGenerator<PK> idGenerator)
static <T extends TreeSupportEntity<PK>,PK> void expandTree2List(T root, List<T> target, IDGenerator<PK> idGenerator, java.util.function.BiConsumer<T,List<T>> childConsumer)
T - 继承TreeSupportEntity的类型PK - 主键类型root - 树结构的根节点target - 目标集合,转换后的数据将直接添加(List.add(Object))到这个集合.idGenerator - ID生成策略static <N extends TreeSupportEntity<PK>,PK> List<N> list2tree(Collection<N> dataList, java.util.function.BiConsumer<N,List<N>> childConsumer)
N - 树节点类型PK - 主键类型dataList - 需要转换的集合childConsumer - 设置子节点回调static <N extends TreeSupportEntity<PK>,PK> List<N> list2tree(Collection<N> dataList, java.util.function.BiConsumer<N,List<N>> childConsumer, java.util.function.Predicate<N> rootNodePredicate)
static <N extends TreeSupportEntity<PK>,PK> List<N> list2tree(Collection<N> dataList, java.util.function.BiConsumer<N,List<N>> childConsumer, java.util.function.Function<TreeSupportEntity.TreeHelper<N,PK>,java.util.function.Predicate<N>> predicateFunction)
N - 元素类型PK - 主键类型dataList - 数据集合childConsumer - 子节点消费接口,用于设置子节点predicateFunction - 根节点判断函数,传入helper,获取一个判断是否为跟节点的函数Copyright © 2016–2020. All rights reserved.