Java Reference
In-Depth Information
Listing 3.1
Once chosen, the fields are used in proven algorithms to implement the
equals and hashCode methods.
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final CurrencyExchangeDataBean currencyExchangeDataBean =
(CurrencyExchangeDataBean) o;
if (exchangeRate != currencyExchangeDataBean.exchangeRate) {
return false;
}
if (startingAmount != currencyExchangeDataBean.startingAmount) {
return false;
}
if (endingCurrency != null
? !endingCurrency.equals(
currencyExchangeDataBean.endingCurrency)
: currencyExchangeDataBean.endingCurrency != null)
return false;
if (startingCurrency != null
? !startingCurrency.equals(
currencyExchangeDataBean.startingCurrency)
: currencyExchangeDataBean.startingCurrency != null)
return false;
return true;
}
public int hashCode() {
int result;
long temp;
result = (startingCurrency != null
? startingCurrency.hashCode() : 0);
result = 29 * result + (endingCurrency != null
? endingCurrency.hashCode() : 0);
temp = startingAmount != +0.0d
? Double.doubleToLongBits(startingAmount) : 0L;
result = 29 * result + (int) (temp ^ (temp >>> 32));
temp = exchangeRate != +0.0d
? Double.doubleToLongBits(exchangeRate) : 0L;
result = 29 * result + (int) (temp ^ (temp >>> 32));
return result;
}
 
Search WWH ::




Custom Search