Last active
November 23, 2015 19:29
-
-
Save ekramalikazi/92ed8037ce4d26b6d496 to your computer and use it in GitHub Desktop.
This file contains 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 characters
import org.apache.commons.lang.builder.EqualsBuilder; | |
import org.apache.commons.lang.builder.HashCodeBuilder; | |
public class Emp { | |
private String name; | |
private int sal; | |
private List<Emp> subordinates; | |
@Override | |
public int hashCode(){ | |
return new HashCodeBuilder() | |
.append(name) | |
.append(sal) | |
.append(subordinates) | |
.toHashCode(); | |
} | |
@Override | |
public boolean equals(final Object obj){ | |
if(obj instanceof Emp){ | |
final Emp other = (Emp) obj; | |
return new EqualsBuilder().append(name, other.name) | |
.append(sal, other.sal) | |
.append(subordinates, other. subordinates) | |
.isEquals(); | |
} else{ | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment