I have a class
public class Step { boolean isActive; String name; } I have a Collection of type Steps. Without using streams this is what I have currently
StringBuilder stringBuilder = new StringBuilder(); for (Step step : steps) { List<String> nextStepNames = getNextStepNames(step); List<String> conditions = getConditions(step); for (int i = 0; i < nextStepNames.size(); i++) { stringBuilder.append("If ").append(step.getName()).append("is active, and condition (").append(conditions.get(i)).append(") is true, then move to ").append(nextStepNames.get(i)).append("\n"); } } If my step collection contains stepA, StepB and stepC, then this is my output:
If stepA is active, and condition (c1A) is true, then move to step1A If stepA is active, and condition (c2A) is true, then move to step2A If stepA is active, and condition (c3A) is true, then move to step3A If stepB is active, and condition (c1B) is true, then move to step1B If stepB is active, and condition (c2B) is true, then move to step2B If stepB is active, and condition (c3B) is true, then move to step3B If stepC is active, and condition (c1C) is true, then move to step1C If stepC is active, and condition (c2C) is true, then move to step2C If stepC is active, and condition (c3C) is true, then move to step3C The nextStepNames and conditions list are the same size and the indexes in the lists correspond to each other.
I haven't been able to convert this code into streams. I not sure if its possible.