First, try sticking to Java naming conventions as your uppercase variable names make it very difficult to read your code. Secondly, itβs good that you want to know about the Stream API, but you should not ignore the basics of the pre-Java 8 Collection APIs.
It is not useful to use iteration over entrySet() when you are only interested in keys, or values. You do this twice in a small piece of code.
At the first appearance you can replace
for (Map.Entry<String, SalesQuot> Quot: Quotations.entrySet()){ SalesQuot sapQuot = Quot.getValue();
with simpler
for (SalesQuot sapQuot: Quotations.values()){
Secondly, the whole
for(Map.Entry<String,SalesQuotPosition> quotp: sapQuot.getPosition().entrySet()){ tempQuotPos.add(quotp.getValue()); }
can be replaced by
tempQuotPos.addAll(sapQuot.getPosition().values());
Thus, even without threads, your code can be simplified to
for (ClassInq simInq : this.Inq){ if (!simInq.isClosed() && !simInq.isDenied()){ for (SalesQuot sapQuot: Quotations.values()){ if (sapQuot.getInquiryDocumentNumber().compareTo(simInq.getSapInquiryNumber()) == 0){ simInq.setSAPQuotationNumber(sapQuot.getQuotationDocumentNumber()); tempInqAndQuot.add(simInq); tempQuotPos.addAll(sapQuot.getPosition().values()); } } } }
although it is still unclear what he should do and whether he is right. Besides the errors and suspicions mentioned in the comments to your question, changing input values ββ(for example, from an external loop) looks wrong.
It is also unclear why you are using β¦.compareTo(β¦)==0 , not equals .
However, it can be directly rewritten to use streams without changing any code logic:
this.Inq.stream().filter(simInq -> !simInq.isClosed() && !simInq.isDenied()) .forEach(simInq -> Quotations.values().stream().filter(sapQuot -> sapQuot.getInquiryDocumentNumber().compareTo(simInq.getSapInquiryNumber())==0) .forEach(sapQuot -> { simInq.setSAPQuotationNumber(sapQuot.getQuotationDocumentNumber()); tempInqAndQuot.add(simInq); tempQuotPos.addAll(sapQuot.getPosition().values()); }) );
However, I recommend that you clear the original logic first before rewriting it to use other APIs. The shape of the flow will greatly benefit from a more precise definition of what to achieve.