Use Preconditions.checkArgument() in NegateExprVisitor

bzip2
Graham 5 years ago
parent 27346725e3
commit 5e616b2d88
  1. 5
      deob-ast/src/main/java/dev/openrs2/deob/ast/visitor/NegateExprVisitor.java

@ -8,14 +8,13 @@ import com.github.javaparser.ast.expr.EnclosedExpr;
import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.expr.UnaryExpr; import com.github.javaparser.ast.expr.UnaryExpr;
import com.github.javaparser.ast.visitor.GenericVisitorWithDefaults; import com.github.javaparser.ast.visitor.GenericVisitorWithDefaults;
import com.google.common.base.Preconditions;
// TODO(gpe): need to be careful about operator precedence/EnclosedExpr // TODO(gpe): need to be careful about operator precedence/EnclosedExpr
public final class NegateExprVisitor extends GenericVisitorWithDefaults<Expression, Void> { public final class NegateExprVisitor extends GenericVisitorWithDefaults<Expression, Void> {
@Override @Override
public Expression defaultAction(Node n, Void arg) { public Expression defaultAction(Node n, Void arg) {
if (!(n instanceof Expression)) { Preconditions.checkArgument(n instanceof Expression);
throw new IllegalArgumentException();
}
return new UnaryExpr((Expression) n, UnaryExpr.Operator.LOGICAL_COMPLEMENT); return new UnaryExpr((Expression) n, UnaryExpr.Operator.LOGICAL_COMPLEMENT);
} }

Loading…
Cancel
Save