diff --git a/modules/i3plus-pojo-aps/src/main/java/cn/estsh/i3plus/pojo/aps/common/BeanRelation.java b/modules/i3plus-pojo-aps/src/main/java/cn/estsh/i3plus/pojo/aps/common/BeanRelation.java index 4dcf88c..9057dad 100644 --- a/modules/i3plus-pojo-aps/src/main/java/cn/estsh/i3plus/pojo/aps/common/BeanRelation.java +++ b/modules/i3plus-pojo-aps/src/main/java/cn/estsh/i3plus/pojo/aps/common/BeanRelation.java @@ -204,10 +204,17 @@ public class BeanRelation { public static List lastList(BaseBean bean, Enum... holders) { List result = new ArrayList<>(); - lastListImpl(result, bean, bean, holders, 0); + lastListImpl(result, bean, bean, null, holders, 0); return result; } - private final static boolean lastListImpl(List result, BaseBean bean, BaseBean self, + + public static List lastList(BaseBean bean, Predicate pred, Enum... holders) { + List result = new ArrayList<>(); + lastListImpl(result, bean, bean, pred, holders, 0); + return result; + } + + private final static boolean lastListImpl(List result, BaseBean bean, BaseBean self, Predicate pred, Enum[] holders, int index) { if (index >= holders.length) { if (self == bean) { @@ -215,15 +222,18 @@ public class BeanRelation { } index = 0; self = bean; + if (pred != null && pred.test((T)bean)) { + return true; + } } boolean bNotLast = true; List nextBeans = list(bean, holders[index]); for (BaseBean nextBean : nextBeans) { - if (lastListImpl(result, nextBean, self, holders, index + 1)) { + if (lastListImpl(result, nextBean, self, pred, holders, index + 1)) { result.add((T)nextBean); - bNotLast = false; } + bNotLast = false; } return index == 0 && bNotLast; }