コード例 #1
0
ファイル: FilterJoinNode.java プロジェクト: wh007/redkale
  private <E> Predicate<E> createJoinPredicate(final AtomicBoolean more) {
    if (column == null && this.nodes == null) return null;
    final EntityCache<E> joinCache = this.joinEntity.getCache();
    Predicate<E> filter = createElementPredicate(joinCache, true);
    if (this.nodes != null) {
      for (FilterNode node : this.nodes) {
        if (((FilterJoinNode) node).joinClass != this.joinClass) {
          more.set(true);
          continue;
        }
        Predicate<E> f = ((FilterJoinNode) node).createJoinPredicate(more);
        if (f == null) continue;
        final Predicate<E> one = filter;
        final Predicate<E> two = f;
        filter =
            (filter == null)
                ? f
                : (or
                    ? new Predicate<E>() {

                      @Override
                      public boolean test(E t) {
                        return one.test(t) || two.test(t);
                      }

                      @Override
                      public String toString() {
                        return "(" + one + " OR " + two + ")";
                      }
                    }
                    : new Predicate<E>() {

                      @Override
                      public boolean test(E t) {
                        return one.test(t) && two.test(t);
                      }

                      @Override
                      public String toString() {
                        return "(" + one + " AND " + two + ")";
                      }
                    });
      }
    }
    return filter;
  }