If we really want code
generation to be flexible, we need to have the ability to choose what code is generated based on external elements. This means that at code generation time, we need to have the ability to chose among different portions of code. If we were to write pure Java code, an
If statement would give us exactly what we are looking for. So our approach will be just this: take advantage of the fact that we can execute Java code to control code generation and always generate the proper code as needed.
For this recipe, we will reuse the KM that was created in the previous recipe. If you did not follow the necessary steps to create the KM, you will need to perform steps 1 through 6 of ...