Commit d9b887a6 authored by Tomas Madeja's avatar Tomas Madeja
Browse files

feat: equals and hashcode for role

parent 5bc1c641
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.util.Objects;
import java.util.Set;

@Entity
@@ -28,4 +29,17 @@ public class Role {

    @ManyToMany(mappedBy = "roles")
    private Set<User> users;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Role)) return false;
        Role role = (Role) o;
        return Objects.equals(getName(), role.getName());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getName());
    }
}