Commit c1945554 authored by miferreiro's avatar miferreiro

The functions of the pet entity, hashCode and equals, have been improved

parent 54cf0352
...@@ -96,10 +96,7 @@ public class Pet { ...@@ -96,10 +96,7 @@ public class Pet {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((specie == null) ? 0 : specie.hashCode());
result = prime * result + id; result = prime * result + id;
result = prime * result + idOwner;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result; return result;
} }
...@@ -109,22 +106,10 @@ public class Pet { ...@@ -109,22 +106,10 @@ public class Pet {
return true; return true;
if (obj == null) if (obj == null)
return false; return false;
if (getClass() != obj.getClass()) if (!(obj instanceof Pet))
return false; return false;
Pet other = (Pet) obj; Pet other = (Pet) obj;
if (specie == null) { if(id != other.id)
if (other.specie != null)
return false;
} else if (!specie.equals(other.specie))
return false;
if (id != other.id)
return false;
if (idOwner != other.idOwner)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false; return false;
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment