001package org.clafer.ast;
002
003import org.clafer.common.Check;
004import org.clafer.common.Util;
005
006/**
007 *
008 * @author jimmy
009 */
010public class AstDecl {
011
012    private final boolean disjoint;
013    private final AstLocal[] locals;
014    private final AstSetExpr body;
015
016    public AstDecl(boolean disjoint, AstLocal[] locals, AstSetExpr body) {
017        this.disjoint = disjoint;
018        this.locals = Check.noNullsNotEmpty(locals);
019        this.body = Check.notNull(body);
020    }
021
022    public boolean isDisjoint() {
023        return disjoint;
024    }
025
026    public AstLocal[] getLocals() {
027        return locals;
028    }
029
030    public AstSetExpr getBody() {
031        return body;
032    }
033
034    public AstDecl withBody(AstSetExpr body) {
035        return new AstDecl(disjoint, locals, body);
036    }
037
038    @Override
039    public String toString() {
040        return (isDisjoint() ? "disj " : "") + Util.intercalate(";", locals) + ":" + body;
041    }
042}