class IfStmt extends Statement implements NodeWithCondition<IfStmt> {

    private Expression condition;

    private Statement thenStmt;

    @OptionalProperty
    private Statement elseStmt;

    public IfStmt() {
        this(null, new BooleanLiteralExpr(), new ReturnStmt(), null);
    }

    @AllFieldsConstructor
    public IfStmt(final Expression condition, final Statement thenStmt, final Statement elseStmt) {
        this(null, condition, thenStmt, elseStmt);
    }

    /**
     * This constructor is used by the parser and is considered private.
     */
    @Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
    public IfStmt(TokenRange tokenRange, Expression condition, Statement thenStmt, Statement elseStmt) {
        super(tokenRange);
        setCondition(condition);
        setThenStmt(thenStmt);
        setElseStmt(elseStmt);
        customInitialization();
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.AcceptGenerator")
    public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
        return v.visit(this, arg);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.AcceptGenerator")
    public <A> void accept(final VoidVisitor<A> v, final A arg) {
        v.visit(this, arg);
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public Expression getCondition() {
        return condition;
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public Optional<Statement> getElseStmt() {
        return Optional.ofNullable(elseStmt);
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public Statement getThenStmt() {
        return thenStmt;
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public IfStmt setCondition(final Expression condition) {<FILL_FUNCTION_BODY>}

    /**
     * Sets the elseStmt
     *
     * @param elseStmt the elseStmt, can be null
     * @return this, the IfStmt
     */
    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public IfStmt setElseStmt(final Statement elseStmt) {
        if (elseStmt == this.elseStmt) {
            return this;
        }
        notifyPropertyChange(ObservableProperty.ELSE_STMT, this.elseStmt, elseStmt);
        if (this.elseStmt != null)
            this.elseStmt.setParentNode(null);
        this.elseStmt = elseStmt;
        setAsParentNodeOf(elseStmt);
        return this;
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public IfStmt setThenStmt(final Statement thenStmt) {
        assertNotNull(thenStmt);
        if (thenStmt == this.thenStmt) {
            return this;
        }
        notifyPropertyChange(ObservableProperty.THEN_STMT, this.thenStmt, thenStmt);
        if (this.thenStmt != null)
            this.thenStmt.setParentNode(null);
        this.thenStmt = thenStmt;
        setAsParentNodeOf(thenStmt);
        return this;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
    public boolean remove(Node node) {
        if (node == null) {
            return false;
        }
        if (elseStmt != null) {
            if (node == elseStmt) {
                removeElseStmt();
                return true;
            }
        }
        return super.remove(node);
    }

    @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
    public IfStmt removeElseStmt() {
        return setElseStmt((Statement) null);
    }

    /**
     * This method returns true if the then branch (which should be always present) is a block statement.
     */
    @DerivedProperty
    public boolean hasThenBlock() {
        return thenStmt instanceof BlockStmt;
    }

    /**
     * This method returns true if the If Statement has an else branch and that branch is a block statement.
     */
    @DerivedProperty
    public boolean hasElseBlock() {
        return elseStmt instanceof BlockStmt;
    }

    /**
     * This method returns true if the If Statement has an else branch and that branch is another If Statement.
     */
    @DerivedProperty
    public boolean hasCascadingIfStmt() {
        return elseStmt instanceof IfStmt;
    }

    /**
     * This method returns true if the If Statement has an else branch.
     */
    @DerivedProperty
    public boolean hasElseBranch() {
        return elseStmt != null;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.CloneGenerator")
    public IfStmt clone() {
        return (IfStmt) accept(new CloneVisitor(), null);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator")
    public IfStmtMetaModel getMetaModel() {
        return JavaParserMetaModel.ifStmtMetaModel;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator")
    public boolean replace(Node node, Node replacementNode) {
        if (node == null) {
            return false;
        }
        if (node == condition) {
            setCondition((Expression) replacementNode);
            return true;
        }
        if (elseStmt != null) {
            if (node == elseStmt) {
                setElseStmt((Statement) replacementNode);
                return true;
            }
        }
        if (node == thenStmt) {
            setThenStmt((Statement) replacementNode);
            return true;
        }
        return super.replace(node, replacementNode);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public boolean isIfStmt() {
        return true;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public IfStmt asIfStmt() {
        return this;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public void ifIfStmt(Consumer<IfStmt> action) {
        action.accept(this);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public Optional<IfStmt> toIfStmt() {
        return Optional.of(this);
    }
}

        assertNotNull(condition);
        if (condition == this.condition) {
            return this;
        }
        notifyPropertyChange(ObservableProperty.CONDITION, this.condition, condition);
        if (this.condition != null)
            this.condition.setParentNode(null);
        this.condition = condition;
        setAsParentNodeOf(condition);
        return this;
    
<methods>public void <init>() ,public void <init>(com.github.javaparser.TokenRange) ,public com.github.javaparser.ast.stmt.AssertStmt asAssertStmt() ,public com.github.javaparser.ast.stmt.BlockStmt asBlockStmt() ,public com.github.javaparser.ast.stmt.BreakStmt asBreakStmt() ,public com.github.javaparser.ast.stmt.ContinueStmt asContinueStmt() ,public com.github.javaparser.ast.stmt.DoStmt asDoStmt() ,public com.github.javaparser.ast.stmt.EmptyStmt asEmptyStmt() ,public com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt asExplicitConstructorInvocationStmt() ,public com.github.javaparser.ast.stmt.ExpressionStmt asExpressionStmt() ,public com.github.javaparser.ast.stmt.ForEachStmt asForEachStmt() ,public com.github.javaparser.ast.stmt.ForStmt asForStmt() ,public com.github.javaparser.ast.stmt.IfStmt asIfStmt() ,public com.github.javaparser.ast.stmt.LabeledStmt asLabeledStmt() ,public com.github.javaparser.ast.stmt.LocalClassDeclarationStmt asLocalClassDeclarationStmt() ,public com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt asLocalRecordDeclarationStmt() ,public com.github.javaparser.ast.stmt.ReturnStmt asReturnStmt() ,public com.github.javaparser.ast.stmt.SwitchStmt asSwitchStmt() ,public com.github.javaparser.ast.stmt.SynchronizedStmt asSynchronizedStmt() ,public com.github.javaparser.ast.stmt.ThrowStmt asThrowStmt() ,public com.github.javaparser.ast.stmt.TryStmt asTryStmt() ,public com.github.javaparser.ast.stmt.UnparsableStmt asUnparsableStmt() ,public com.github.javaparser.ast.stmt.WhileStmt asWhileStmt() ,public com.github.javaparser.ast.stmt.YieldStmt asYieldStmt() ,public com.github.javaparser.ast.stmt.Statement clone() ,public com.github.javaparser.metamodel.StatementMetaModel getMetaModel() ,public void ifAssertStmt(Consumer<com.github.javaparser.ast.stmt.AssertStmt>) ,public void ifBlockStmt(Consumer<com.github.javaparser.ast.stmt.BlockStmt>) ,public void ifBreakStmt(Consumer<com.github.javaparser.ast.stmt.BreakStmt>) ,public void ifContinueStmt(Consumer<com.github.javaparser.ast.stmt.ContinueStmt>) ,public void ifDoStmt(Consumer<com.github.javaparser.ast.stmt.DoStmt>) ,public void ifEmptyStmt(Consumer<com.github.javaparser.ast.stmt.EmptyStmt>) ,public void ifExplicitConstructorInvocationStmt(Consumer<com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt>) ,public void ifExpressionStmt(Consumer<com.github.javaparser.ast.stmt.ExpressionStmt>) ,public void ifForEachStmt(Consumer<com.github.javaparser.ast.stmt.ForEachStmt>) ,public void ifForStmt(Consumer<com.github.javaparser.ast.stmt.ForStmt>) ,public void ifIfStmt(Consumer<com.github.javaparser.ast.stmt.IfStmt>) ,public void ifLabeledStmt(Consumer<com.github.javaparser.ast.stmt.LabeledStmt>) ,public void ifLocalClassDeclarationStmt(Consumer<com.github.javaparser.ast.stmt.LocalClassDeclarationStmt>) ,public void ifLocalRecordDeclarationStmt(Consumer<com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt>) ,public void ifReturnStmt(Consumer<com.github.javaparser.ast.stmt.ReturnStmt>) ,public void ifSwitchStmt(Consumer<com.github.javaparser.ast.stmt.SwitchStmt>) ,public void ifSynchronizedStmt(Consumer<com.github.javaparser.ast.stmt.SynchronizedStmt>) ,public void ifThrowStmt(Consumer<com.github.javaparser.ast.stmt.ThrowStmt>) ,public void ifTryStmt(Consumer<com.github.javaparser.ast.stmt.TryStmt>) ,public void ifUnparsableStmt(Consumer<com.github.javaparser.ast.stmt.UnparsableStmt>) ,public void ifWhileStmt(Consumer<com.github.javaparser.ast.stmt.WhileStmt>) ,public void ifYieldStmt(Consumer<com.github.javaparser.ast.stmt.YieldStmt>) ,public boolean isAssertStmt() ,public boolean isBlockStmt() ,public boolean isBreakStmt() ,public boolean isContinueStmt() ,public boolean isDoStmt() ,public boolean isEmptyStmt() ,public boolean isExplicitConstructorInvocationStmt() ,public boolean isExpressionStmt() ,public boolean isForEachStmt() ,public boolean isForStmt() ,public boolean isIfStmt() ,public boolean isLabeledStmt() ,public boolean isLocalClassDeclarationStmt() ,public boolean isLocalRecordDeclarationStmt() ,public boolean isReturnStmt() ,public boolean isSwitchStmt() ,public boolean isSynchronizedStmt() ,public boolean isThrowStmt() ,public boolean isTryStmt() ,public boolean isUnparsableStmt() ,public boolean isWhileStmt() ,public boolean isYieldStmt() ,public Optional<com.github.javaparser.ast.stmt.AssertStmt> toAssertStmt() ,public Optional<com.github.javaparser.ast.stmt.BlockStmt> toBlockStmt() ,public Optional<com.github.javaparser.ast.stmt.BreakStmt> toBreakStmt() ,public Optional<com.github.javaparser.ast.stmt.ContinueStmt> toContinueStmt() ,public Optional<com.github.javaparser.ast.stmt.DoStmt> toDoStmt() ,public Optional<com.github.javaparser.ast.stmt.EmptyStmt> toEmptyStmt() ,public Optional<com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt> toExplicitConstructorInvocationStmt() ,public Optional<com.github.javaparser.ast.stmt.ExpressionStmt> toExpressionStmt() ,public Optional<com.github.javaparser.ast.stmt.ForEachStmt> toForEachStmt() ,public Optional<com.github.javaparser.ast.stmt.ForStmt> toForStmt() ,public Optional<com.github.javaparser.ast.stmt.IfStmt> toIfStmt() ,public Optional<com.github.javaparser.ast.stmt.LabeledStmt> toLabeledStmt() ,public Optional<com.github.javaparser.ast.stmt.LocalClassDeclarationStmt> toLocalClassDeclarationStmt() ,public Optional<com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt> toLocalRecordDeclarationStmt() ,public Optional<com.github.javaparser.ast.stmt.ReturnStmt> toReturnStmt() ,public Optional<com.github.javaparser.ast.stmt.SwitchStmt> toSwitchStmt() ,public Optional<com.github.javaparser.ast.stmt.SynchronizedStmt> toSynchronizedStmt() ,public Optional<com.github.javaparser.ast.stmt.ThrowStmt> toThrowStmt() ,public Optional<com.github.javaparser.ast.stmt.TryStmt> toTryStmt() ,public Optional<com.github.javaparser.ast.stmt.UnparsableStmt> toUnparsableStmt() ,public Optional<com.github.javaparser.ast.stmt.WhileStmt> toWhileStmt() ,public Optional<com.github.javaparser.ast.stmt.YieldStmt> toYieldStmt() <variables>