0

What would be the equivalent lambda expression for streaming through a list of objects. Then checking an objects attribute for a value and setting another attribute in the same object based on that value. Example:

List<OptionOverrideChangeOrderModel> quoteOptions = 
Collections.singletonList(quoteOption);
        
for (OptionOverrideChangeOrderModel option : quoteOptions) {
    if (option.getFet() > 0) {
        option.setApplyFet(true);
    }
}

1 Answer 1

2

It would be:

quoteOptions
  .stream()
  .filter(el -> el.getFet() > 0)
  .foreach(el -> el.setApplyFet(true))
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Alberto!
@TonyNeves feel free to mark this as correct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.