예제 #1
0
  private Trail handleTrue(Trail trail, Node node, EvaluationContext context) {

    // A "true" leaf node
    if (!node.hasNodes()) {
      return trail.selectNode(node);
    }

    trail.push(node);

    List<Node> children = node.getNodes();
    for (int i = 0, max = children.size(); i < max; i++) {
      Node child = children.get(i);

      Boolean status = evaluateNode(trail, child, context);

      if (status == null) {
        Trail destination = handleMissingValue(trail, node, child, context);

        if (destination != null) {
          return destination;
        }
      } else if (status.booleanValue()) {
        return handleTrue(trail, child, context);
      }
    }

    // A "true" non-leaf node
    return handleNoTrueChild(trail);
  }
예제 #2
0
            private ImmutableBiMap.Builder<String, Node> collectNodes(
                Node node, AtomicInteger index, ImmutableBiMap.Builder<String, Node> builder) {
              builder = EntityUtil.put(node, index, builder);

              if (!node.hasNodes()) {
                return builder;
              }

              List<Node> children = node.getNodes();
              for (Node child : children) {
                builder = collectNodes(child, index, builder);
              }

              return builder;
            }