001package org.clafer.ast; 002 003import org.clafer.common.Check; 004 005/** 006 * 007 * @author jimmy 008 */ 009public class AstIfThenElse implements AstBoolExpr { 010 011 private final AstBoolExpr antecedent; 012 private final AstBoolExpr consequent; 013 private final AstBoolExpr alternative; 014 015 AstIfThenElse(AstBoolExpr antecedent, AstBoolExpr consequent, AstBoolExpr alternative) { 016 this.antecedent = Check.notNull(antecedent); 017 this.consequent = Check.notNull(consequent); 018 this.alternative = Check.notNull(alternative); 019 } 020 021 public AstBoolExpr getAntecedent() { 022 return antecedent; 023 } 024 025 public AstBoolExpr getConsequent() { 026 return consequent; 027 } 028 029 public AstBoolExpr getAlternative() { 030 return alternative; 031 } 032 033 @Override 034 public <A, B> B accept(AstExprVisitor<A, B> visitor, A a) { 035 return visitor.visit(this, a); 036 } 037 038 @Override 039 public String toString() { 040 return "if " + antecedent + " then " + consequent + " else " + alternative; 041 } 042}