I have this two methods:
for (RuntimeProductOfferEntity productOfferEntity : eligibleOffers) {
if (productOfferEntity.getSalesSubCategory().equalsIgnoreCase(nonBillable.getSubCategory())
&& Boolean.TRUE.equals(filterByCharacteristcs(productOfferEntity, nonBillable.getDuration().toString()))) {
productOffers.add(ProductOfferResponse.builder().categoryId(nonBillable.getCategoryId())
.offerCode(productOfferEntity.getCode()).build());
}
}
And my method where i user foreach:
private Boolean filterByCharacteristcs(final RuntimeProductOfferEntity offer, final String duration) {
for (RuntimeTemplateEntity template : offer.getTemplates()) {
for (RuntimeCharacteristicEntity charateristic : template.getCharacteristics()) {
if ("VARIJACIJA".equalsIgnoreCase(charateristic.getCode())) {
for (RuntimeCharacteristicValueEntity value : charateristic.getCharacteristicValues()) {
if (duration.equalsIgnoreCase(value.getValue())) {
return Boolean.TRUE;
}
}
}
}
}
return Boolean.FALSE;
}
Is there any way to use stream and not to use this multiple foreach?