Overrode RecipeStarId equals() and hashcode().
This commit is contained in:
parent
710f0d7c00
commit
40b315bb08
@ -3,6 +3,8 @@ package app.mealsmadeeasy.api.recipe.star;
|
|||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Embeddable;
|
import jakarta.persistence.Embeddable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class RecipeStarId {
|
public class RecipeStarId {
|
||||||
|
|
||||||
@ -28,6 +30,20 @@ public class RecipeStarId {
|
|||||||
this.recipeId = recipeId;
|
this.recipeId = recipeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof RecipeStarId other) {
|
||||||
|
return this.recipeId.equals(other.recipeId) && this.ownerUsername.equals(other.ownerUsername);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(this.recipeId, this.ownerUsername);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RecipeStarId(" + this.recipeId + ", " + this.ownerUsername + ")";
|
return "RecipeStarId(" + this.recipeId + ", " + this.ownerUsername + ")";
|
||||||
|
Loading…
Reference in New Issue
Block a user