I have a function to model my Data. If the parameter "Entity" contains child, it is enclosed in child names. There are two types of child Type-A & Type-B. For Each type the function is called recursively. This recursive function call exits when the child do not have any more child names.
public void modelMyData(Entity entity) {
if (entity.getChildNames()[0] != null) {
Arrays.stream(entity.getChildNames())
.collect(Collectors.toList())
.parallelStream()
.forEach(childType -> {
entity.getChild(childType).parallelStream()
.forEach(child -> {
modelMyData(child);
});
;
});
}
System.out.println("INSERT " + entity.getChildAttributeValue());
}
The program works fine for me. But the use of parallel stream is said to be bad in java programming.
Visit http://zeroturnaround.com/rebellabs/java-parallel-streams-are-bad-for-your-health/
Should I use streams instead of parallel streams?