class Disjunction extends BooleanExpr {

  @Override
  public BooleanExpr simplify() {
    if (_simplified != null) {
      return _simplified;
    }
    ImmutableList.Builder<BooleanExpr> simpleDisjunctsBuilder = ImmutableList.builder();
    for (BooleanExpr disjunct : _disjuncts) {
      BooleanExpr simpleDisjunct = disjunct.simplify();
      if (simpleDisjunct.equals(BooleanExprs.FALSE)) {
        // Skip false.
        continue;
      }
      simpleDisjunctsBuilder.add(simpleDisjunct);
      if (simpleDisjunct.equals(BooleanExprs.TRUE)) {
        // Short-circuit the disjunction after the last true.
        break;
      }
    }
    List<BooleanExpr> simpleDisjuncts = simpleDisjunctsBuilder.build();
    if (simpleDisjuncts.isEmpty()) {
      _simplified = BooleanExprs.FALSE;
    } else if (simpleDisjuncts.size() == 1) {
      _simplified = simpleDisjuncts.get(0);
    } else {
      Disjunction simple = new Disjunction();
      simple.setDisjuncts(simpleDisjuncts);
      simple.setComment(getComment());
      _simplified = simple;
      simple._simplified = _simplified;
    }
    return _simplified;
  }

  public  Disjunction();
  public  Disjunction(BooleanExpr... disjuncts);
  public  Disjunction(List<BooleanExpr> disjuncts);

}