I have a java object with 3 layers.
the scenario has several sections:
public class Scenario {
private String scenarioId;
private List<Section> sectionList;
within each section, there are several labels:
public class Section {
private String sectionName;
private List<String> labelList;
I want to assemble the 3 layer data into one string, like:
<Scenario>
<section1>
<label11 data>
<label12 data>
<section2>
<label21 data>
<label22 data>
...
I have the code as following to pick each layers' parameter, but how to assemble it into one string:
String scenarioId = scenario.getScenarioId();
List<Section> sectionList = scenario.getSectionList();
sectionList.forEach(section -> {
String sectionName = section.getSectionName();
List<String> labelList = section.getLabelList();
String data;
if(!labelList.isEmpty()) {
data =copy.LabelData(labelList, input);
}
});
return scenario;