I have stream of Integer or Long. I wan to add the element of the stream one by one and compare it with one fixed value after each addition if it met certain criteria need to break the addition and return the value. If we use reduction it will add all the element of the stream but I want add elements until certain condtion is met the break.
Ex
fixed value = 15
1,2,3,4,5,6 --> (1+2+3+4+5) = 15 at this point stop the addition and return this value of some other value like 1 if not equal 15 then return 0.