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

net.sourceforge.pmd.lang.java.ast.ASTAssertStatement Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
/**
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */

package net.sourceforge.pmd.lang.java.ast;

/**
 * Represents an {@code assert} statement.
 *
 * 
 *
 * AssertStatement ::= "assert" {@linkplain ASTExpression Expression} ( ":" {@linkplain ASTExpression Expression} )? ";"
 *
 * 
*/ public final class ASTAssertStatement extends AbstractStatement { ASTAssertStatement(int id) { super(id); } @Override protected R acceptVisitor(JavaVisitor visitor, P data) { return visitor.visit(this, data); } /** * Returns the expression tested by this assert statement. */ public ASTExpression getCondition() { return (ASTExpression) getChild(0); } /** * Returns true if this assert statement has a "detail message" * expression. In that case, {@link #getDetailMessageNode()} doesn't * return null. */ public boolean hasDetailMessage() { return getNumChildren() == 2; } /** * Returns the expression that corresponds to the detail message, * i.e. the expression after the colon, if it's present. */ public ASTExpression getDetailMessageNode() { return hasDetailMessage() ? (ASTExpression) getChild(1) : null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy