Here is a basic version
public class TestClass implements Serializable{
    private static final long serialVersionUID = -6529629340276202620L;
    private Integer accountId;
    private String accountName;
    public Integer getAccountId() {
        return accountId;
    }
    public void setAccountId(Integer accountId) {
        this.accountId = accountId;
    }
    public String getAccountName() {
        return accountName;
    }
    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }
    @Override
    public int hashCode() {
final int PRIME = 31;
int result = 1;
result= PRIME* result+ ((accountId ==null) ? 0 : accountId.hashCode());
result= PRIME* result+ ((accountName ==null) ? 0 : accountName.hashCode());
return result;
}
final int PRIME = 31;
int result = 1;
result= PRIME* result+ ((accountId ==null) ? 0 : accountId.hashCode());
result= PRIME* result+ ((accountName ==null) ? 0 : accountName.hashCode());
return result;
}
  @Override
    public boolean equals(Object obj) {
if (this == obj)
return true;
        
if (obj == null)
return false;
        
if ( getClass () != obj.getClass () )
return false;
        
final TestClass other = (TestClass) obj;
        
if (accountId == null){
if (other.getAccountId() !=null)
return false;
else if (!accountId.equals(other.getAccountId()))
return false;
}
        
if (accountName == null){
if (other.getAccountName() !=null)
return false;
else if (!accountName.equals(other.getAccountName()))
return false;
}
        
return true;
}
if (this == obj)
return true;
if (obj == null)
return false;
if ( getClass () != obj.getClass () )
return false;
final TestClass other = (TestClass) obj;
if (accountId == null){
if (other.getAccountId() !=null)
return false;
else if (!accountId.equals(other.getAccountId()))
return false;
}
if (accountName == null){
if (other.getAccountName() !=null)
return false;
else if (!accountName.equals(other.getAccountName()))
return false;
}
return true;
}
}  
 
No comments:
Post a Comment