001package gudusoft.gsqlparser.ir.logical.rex;
002
003import gudusoft.gsqlparser.ir.common.SourceAnchor;
004import gudusoft.gsqlparser.ir.logical.RexNode;
005import gudusoft.gsqlparser.ir.logical.RexNodeVisitor;
006
007/**
008 * CAST expression.
009 */
010public final class RexCast extends RexNode {
011    private final RexNode operand;
012    private final String targetType;
013
014    public RexCast(RexNode operand, String targetType, SourceAnchor anchor) {
015        super(RexKind.CAST, anchor);
016        this.operand = operand;
017        this.targetType = targetType;
018    }
019
020    public RexNode getOperand() { return operand; }
021    public String getTargetType() { return targetType; }
022
023    @Override
024    public <R> R accept(RexNodeVisitor<R> visitor) { return visitor.visitCast(this); }
025
026    @Override
027    public String toString() { return "CAST(" + operand + " AS " + targetType + ")"; }
028}