Say I have following java POJOs
class Outer {
Config;
List<Warning> warnings;
}
class Config {
String configId;
String configName;
}
class Warning {
String warningId;
String warningName;
}
class Transformed {
String configId
String configName;
String warningId;
String warningName;
}
Desired output
List<Transformed>
In an ideal world where for ever instance of Outer, if warnings
were always present I could use Java 8 streams and transform into List<Transformed
. But List<Warning> warnings
can be null in some cases of input. One might say, use something like Stream.ofNullable
when doing an inner stream. This will not work in my use case because I still want the Tranformed
instance to have the fields String configId
and String configName
populated even if the warning fields are null. How do I do it with Java 8 streams, and filter combo? What is the ideal way? Or I just go the plain old fashioned nested looping way with null checks and all?
1