package nl.eernie.jmoribus.model;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class Step  {

    private StepType stepType;
    private List<StepLine> stepLines = new ArrayList<>();

    public Step(StepType stepType) {
        this.stepType = stepType;
    }

    public StepType getStepType() {
        return stepType;
    }

    public StepLine getFirstStepLine()
    {
        return stepLines.get(0);
    }

    public List<StepLine> getStepLines()
    {
        return stepLines;
    }

    public String getCombinedStepLines(){
        String combined = "";
        for(StepLine stepLine: stepLines){
            if(StringUtils.isNotBlank(combined)){
                combined = combined + " ";
            }
            if(stepLine instanceof Table){
                int index = stepLines.indexOf(stepLine);
                combined = combined + "TABLE"+index;
            }else{
                combined = combined + stepLine.getText();
            }
        }
        return combined;
    }
}

@@ -609,22 +609,42 @@
 ring
- combined = %22%22
+Buffer buffer = new StringBuffer()
 ;%0A  
@@ -722,24 +722,33 @@
 otBlank(
-combined
+buffer.toString()
 ))%7B%0A    
@@ -763,33 +763,26 @@
     
-combined = combined + 
+buffer.append(
 %22 %22
+)
 ;%0A  
@@ -909,38 +909,30 @@
         
-combined = combined + 
+buffer.append(
 %22TABLE%22+
@@ -936,16 +936,17 @@
 E%22+index
+)
 ;%0A      
@@ -978,30 +978,22 @@
     
-combined = combined + 
+buffer.append(
 step
@@ -1006,16 +1006,17 @@
 etText()
+)
 ;%0A      
@@ -1052,16 +1052,25 @@
 urn 
-combined
+buffer.toString()
 ;%0A  

Remove defect for building a string in a loop