# Interface: com.pnfsoftware.jeb.core.units.code.java.IJavaIf

Java AST interface to represent a conditional "if" statement. 

 An if\-statement consists of one or more branches \(if, else\-if\) followed by an optional default branch \(else\) block. 

 Example:  

```

 if(p)
   b
 else if(p1)
   b1
 else
   b2
 
```

## Method: addBranch
- parameter: `p`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaPredicate`
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Add an alternative block \(if or else\-if\) to this element.
parameter: p: mandatory predicate
parameter: b: mandatory statement

## Method: duplicate
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaIf`


## Method: getBranchBody
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Get a branch \(if, else\-if\) body.
parameter: index: 0\-based branch index \(0 for 'if', 1... for subsequent else\-ifs\)
return: the body

## Method: getBranchPredicate
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaPredicate`

Description: Get a branch \(if, else\-if\) predicate.
parameter: index: 0\-based branch index \(0 for 'if', 1... for subsequent else\-ifs\)
return: the predicate

## Method: getBranchPredicates
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.java.IJavaPredicate>`

Description: Get the predicates. Warning, this is the actual list of predicates, not a copy. Caution should be exercised when modifying it
return: the original list of predicates

## Method: getDefaultBlock
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Get the default branch \(else\) body, if any.
return: the default branch body, null if there is none

## Method: hasDefaultBlock
- return type: `boolean`

Description: Determine whether that if\-statement has a default block.
return: true if the if\-statement has an else block

## Method: insertBranch
- parameter: `index`, type: `int`
- parameter: `p`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaPredicate`
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Insert a branch \(if, else\-if\) to this statement.
parameter: index: 0\-based branch index
parameter: p: mandatory predicate
parameter: b: mandatory body

## Method: removeBranch
- parameter: `index`, type: `int`

Description: Remove a branch from this statement.
parameter: index: 0\-based branch index

## Method: setBranchBody
- parameter: `index`, type: `int`
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Set a branch \(if, else\-if\) body.
parameter: index: 0\-based branch index
parameter: b: mandatory body

## Method: setBranchPredicate
- parameter: `index`, type: `int`
- parameter: `p`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaPredicate`

Description: Set a branch \(if, else\-if\) predicate.
parameter: index: 0\-based branch index
parameter: p: mandatory predicate

## Method: setDefaultBlock
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Set the default 'else' block.
parameter: b: new default block, null for none
return: the previous default block

## Method: size
- return type: `int`

Description: Get the number of branches, including the default \(else\) branch, if any.
return: the number of branches

## Method: sizeWithoutDefault
- return type: `int`

Description: Return the number of blocks \(if, else\-ifs\), NOT counting the else block if there is one.
return: 

