Multiple OR conditions in if statements
<p>I have created a method that uses an iterator that iterates through a map and for each pair it evaluates a statement with many OR conditions. If the condition is true, it adds the object of the pair (a Notification object) in a list (anomalies). However, at compilation time, the compiler gives a NullPointerException exception at this method. Based on my investigation, it seems that there is a problem in the if statement, but I can't see why. Can anyone give me an help in this? Thanks!</p>

<pre><code>public List&lt;Notification&gt; getAnomalies(NotificationSearchCriteria notificationSearchCriteria) {

 Map&lt;String,Notification&gt; messageList = new HashMap&lt;String,Notification&gt;();
List&lt;Notification&gt; anomalies = new ArrayList&lt;Notification&gt;();

Iterator iterator = messageList.entrySet().iterator();
while (iterator.hasNext()) {

    Map.Entry pairs = (Map.Entry)iterator.next();
    Notification message = (Notification) pairs.getValue();

           if(message.getDescription().equals(notificationSearchCriteria.getDescription())||message.getSubjectName().equals(notificationSearchCriteria.getSubjectName())||message.getNotificationSubject().toString().equals(notificationSearchCriteria.getNotificationSubject().toString())||message.getNotificationType().toString().equals(notificationSearchCriteria.getNotificationType().toString())){

               anomalies.add(message);

             }
        }

    }
    return anomalies;
}
</code></pre>
