All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dataflow.src.org.checkerframework.dataflow.cfg.node.TernaryExpressionNode Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java’s type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.42.0
Show newest version
package org.checkerframework.dataflow.cfg.node;

import java.util.Collection;
import java.util.LinkedList;

import org.checkerframework.dataflow.util.HashCodeUtils;

import org.checkerframework.javacutil.InternalUtils;

import com.sun.source.tree.ConditionalExpressionTree;
import com.sun.source.tree.Tree.Kind;

/**
 * A node for a conditional expression:
 *
 * 
 *   expression ? expression : expression
 * 
* * @author Stefan Heule * @author Charlie Garrett * */ public class TernaryExpressionNode extends Node { protected ConditionalExpressionTree tree; protected Node condition; protected Node thenOperand; protected Node elseOperand; public TernaryExpressionNode(ConditionalExpressionTree tree, Node condition, Node thenOperand, Node elseOperand) { super(InternalUtils.typeOf(tree)); assert tree.getKind().equals(Kind.CONDITIONAL_EXPRESSION); this.tree = tree; this.condition = condition; this.thenOperand = thenOperand; this.elseOperand = elseOperand; } public Node getConditionOperand() { return condition; } public Node getThenOperand() { return thenOperand; } public Node getElseOperand() { return elseOperand; } @Override public ConditionalExpressionTree getTree() { return tree; } @Override public R accept(NodeVisitor visitor, P p) { return visitor.visitTernaryExpression(this, p); } @Override public String toString() { return "(" + getConditionOperand() + " ? " + getThenOperand() + " : " + getElseOperand() + ")"; } @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof TernaryExpressionNode)) { return false; } TernaryExpressionNode other = (TernaryExpressionNode) obj; return getConditionOperand().equals(other.getConditionOperand()) && getThenOperand().equals(other.getThenOperand()) && getElseOperand().equals(other.getElseOperand()); } @Override public int hashCode() { return HashCodeUtils.hash(getConditionOperand(), getThenOperand(), getElseOperand()); } @Override public Collection getOperands() { LinkedList list = new LinkedList(); list.add(getConditionOperand()); list.add(getThenOperand()); list.add(getElseOperand()); return list; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy