List<Person> personsInOMwithTypeDsc = personsInOm.stream()
.filter(e -> e.getPersonType().getPersonTypeId() ==1 )
.forEach(personTypeList.stream()
.foreach(d -> d.getPersonTypeId() == 1 )
.map(Person::setPersonType(d))
.collect(Collectors.toList());
I want to assign a value to a variable in the first object if the condition in the inner loop matches. Is that possible in java streams ?
Without knowing much about your types...
List<Person> persons = /*you're getting this from somewhere*/;
persons.stream()
.filter(person -> person.isSatisfiedByYourConditon())
.forEach(person -> person.setSomeField("new value"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With