package models;

import com.avaje.ebean.Ebean;
import org.hibernate.validator.constraints.Email;
import play.data.validation.Constraints;
import play.db.ebean.Model;
import play.db.ebean.Transactional;

import javax.persistence.*;
import java.util.*;

@Entity
public class User extends Model {

    public static Finder<String, User> find = new Finder<>(String.class, User.class);

    public enum Gender {
        MALE, FEMALE;
    }

    @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "user")
    public List<Membership> memberships = new ArrayList<>();

    @Id
    @Constraints.Required
    public String id;

    @Constraints.Required
    public String firstName;

    @Constraints.Required
    public String lastName;

    @Constraints.Required
    public Gender gender;

    @Constraints.Required
    @Email
    public String email;

    @Constraints.Required
    public String pictureUrl;

    public User(String id, String firstName, String lastName, Gender gender, String email, String picureUrl) {

        this.id = id;
        this.firstName = firstName;
        this.lastName = lastName;
        this.gender = gender;
        this.email = email;
        this.pictureUrl = picureUrl;
    }

    public static User findById(String id) {return find.where().eq("id", id).findUnique();}
    public static User findByName(String firstName, String lastName) {
        return find.where().eq("firstName", firstName).eq("lastName", lastName).findUnique();
    }

    public static boolean exists(String id) {return find.where().eq("id", id).findRowCount() != 0;}

    @Transactional
    public static void save(User user) {

        if(!exists(user.id))
            Ebean.save(user);
    }

    public static List<String> genderAsList(){
        ArrayList<String> list = new ArrayList<>();

        for(Gender gender : Gender.values()) { list.add(gender.name());}
        return list;
    }
}

@@ -1894,11 +1894,464 @@
 t;%0A    %7D
+%0A%0A    @Override%0A    public boolean equals(final Object o) %7B%0A        if (this == o) return true;%0A        if (o == null %7C%7C getClass() != o.getClass()) return false;%0A        if (!super.equals(o)) return false;%0A%0A        final User user = (User) o;%0A%0A        return id.equalsIgnoreCase(user.id);%0A%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        int result = super.hashCode();%0A        result = 31 * result + id.hashCode();%0A        return result;%0A    %7D
 %0A%7D%0A

Create equals() for User model