Actually I want to throw two exceptions as part of checking two conditions. But wondering how to throw these exceptions after streaming and mapping it.
This is the code to be converted to Java-8 Using Streams
for(GroupCallCenter existingGroupCall : group.getGroupCallCenters())
{
if(!existingGroupCall.getCallCenter()
.getId().equals(accountCallCenterResource.getCallCenterId()))
{
if(!accountCallCenterResource.getValidity().getEffectiveStarting().isAfter(existingGroupCall.getExpirationDate())&&!existingGroupCall.getEffectiveDate().isAfter(accountCallCenterResource.getValidity().getExpiresAfter()))
{
throw new ApiException(ApiErrorCode.DEFAULT_400, "Group call
center already exist for that period");
}
}
else {
throw new DuplicateException(ApiErrorCode.DUPLICATE,
existingGroupCall.getId());
}
}