Implementing equals & hashcode for ArrayList.contains() not working
<p>My attempt to customize the method contains of ArrayList, I used Eclipse to generate these methods inside a class TaskCandidateListItemDo</p>

<pre><code>@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result;

    if (keyValue == null) {
        result += 0;
    } else {
        result += keyValue.hashCode();
    }

    return result;
}

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }

    TaskOverrideItemDo other = (TaskOverrideItemDo) obj;

    if (keyValue == null) {
        if (other.keyValue != null) {
            return false;
        }
    } else if (!keyValue.equals(other.keyValue)) {
        return false;
    }
    return true;
}
</code></pre>

<p>And here's is how I use it</p>

<pre><code>taskCandidateList = (List&lt;TaskCandidateListItemDo&gt;) namedQuery.list();

for (TaskOverrideItemDo taskOverrideItemDo : validateOverrideListSearchCriteriaDo
        .getTaskOverrideItemDoList()) {

    if (taskCandidateList.contains(taskOverrideItemDo.getKeyValue())) {
       // do some code
    }
}
</code></pre>

<p>My list declared as followed</p>

<pre><code>private List&lt;TaskCandidateListItemDo&gt; taskCandidateList;
</code></pre>

<p>The // do some code inside the if statement is never executed even if keyValue exist. Also, the break point wouldnt stop at the equals method..</p>
