JavaTXCompilerInJavaTX/javatx-src/main/java/de/dhbwstuttgart/syntaxtree/GuardedPattern.java

36 lines
921 B
Java
Raw Normal View History

2024-02-02 12:06:37 +00:00
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public class GuardedPattern extends Pattern {
private final Expression condition;
private final Pattern nested;
public GuardedPattern(Expression condition, Pattern nested, Token offset) {
super(nested.getType(), offset);
this.condition = condition;
this.nested = nested;
}
public Expression getCondition() {
return condition;
}
public Pattern getNestedPattern() {
return nested;
}
@Override
public void accept(ASTVisitor visitor) {
visitor.visit(this);
}
@Override
public GuardedPattern withType(RefTypeOrTPHOrWildcardOrGeneric type) {
return new GuardedPattern(condition, nested, getOffset());
}
}