|
|
|
@ -204,10 +204,17 @@ public class BeanRelation {
|
|
|
|
|
|
|
|
|
|
public static <T extends BaseBean> List<T> lastList(BaseBean bean, Enum<?>... holders) {
|
|
|
|
|
List<T> result = new ArrayList<>();
|
|
|
|
|
lastListImpl(result, bean, bean, holders, 0);
|
|
|
|
|
lastListImpl(result, bean, bean, null, holders, 0);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
private final static <T extends BaseBean> boolean lastListImpl(List<T> result, BaseBean bean, BaseBean self,
|
|
|
|
|
|
|
|
|
|
public static <T extends BaseBean> List<T> lastList(BaseBean bean, Predicate<T> pred, Enum<?>... holders) {
|
|
|
|
|
List<T> result = new ArrayList<>();
|
|
|
|
|
lastListImpl(result, bean, bean, pred, holders, 0);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final static <T extends BaseBean> boolean lastListImpl(List<T> result, BaseBean bean, BaseBean self, Predicate<T> 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<BaseBean> 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;
|
|
|
|
|
}
|
|
|
|
|