My Object :
List<Test>
.
.
.
Test {
String name;
String salary;
List<String> nickNames;}
I would like to convert this list to an ImmutableList (ie)
ImmutableList<Test>
where nickNames in Test must also be converted into an ImmuatableList
I could do something like this
listOfObjects()
.stream()
.map(obj -> {obj.setNickNames(ImmutableList.copyOf(obj.getNickNames)); return obj;})
.collect(ImmutableList.toImmutableList());
But is there any other cleaner way to achieve this ?