This job is talking about 30+ hours of time. This Iterator holds 800k records and the loop has to execute for each record and there are about 20+ of these checks in the same method. How can I avoid the cyclomatic complexity here?
CustomerPreference newRecord = null;
while (iterator.hasNext())
{
final CustomerPreference current = iterator.next();
if (newRecord != null)
{
if (!newRecord.getEmail().equals(current.getEmail()))
{
resList.add(newRecord);
newRecord = current;
}
}
else
{
newRecord = current;
}
if (null != current.getEmailPref())
{
newRecord.setEmailPref(current.getHdCaEmailPref());
}
else
{
if (newRecord.getEmailPref() == null)
{
newRecord.setEmailPref(NO_CHANGE);
}
}