Java "contains" not working properly
<p>My class:</p>

<pre><code>public class UserProgressModel {

    private String email;

    public UserProgressModel(String pEmail) {
        super();

        this.email = pEmail;
    }

    @Override
    public boolean equals(Object x) {

        if (x != null &amp;&amp; x instanceof UserProgressModel
                &amp;&amp; ((UserProgressModel) x).email.equals(this.email) == true) {

            return true;
        }

        if (x != null &amp;&amp; x instanceof String
                &amp;&amp; x.equals(this.email) == true) {

            return true;
        }

        return false;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 17 * hash + (this.email != null ? this.email.hashCode() : 0);
        return hash;
    }
}
</code></pre>

<p>And after putting some objects via gson:</p>

<pre><code>UserProgressModel[] userProgressArray;
List&lt;UserProgressModel&gt; retUserProgress = new ArrayList&lt;&gt;();

userProgressArray = gs.fromJson(fileContents,
                        new TypeToken&lt;UserProgressModel[]&gt;() {
                        }.getType());

for (UserProgressModel ele : userProgressArray) {

    if (ele != null) {
        retUserProgress.add(ele);
    }
}
</code></pre>

<p>I am unable to get true for the following code:</p>

<pre><code>retUserProgress.contains("test@test.com");
</code></pre>

<p>I looped thru the array to verify that one object has the email.</p>

<p>Am I doing right? I think I have overridden the equals &amp; hashcode.</p>