Created
October 24, 2024 09:44
-
-
Save karthiks/9290d9d94e76506663c124fcf5673162 to your computer and use it in GitHub Desktop.
Revisions
-
karthiks created this gist
Oct 24, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ public class Person { private Long id; private String name; @Override public int hashCode() { return Objects.hash(id, name); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Person other = (Person) obj; return Objects.equals(id, other.id) && Objects.equals(name, other.name); } } class Address { private String road; private String city; private String pincode; @Override public int hashCode() { return Objects.hash(city, pincode, road); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Address other = (Address) obj; return Objects.equals(city, other.city) && Objects.equals(pincode, other.pincode) && Objects.equals(road, other.road); } }