task4/solution11/src/org/apidesign/apifest08/currency/StaticExchangeRateProvider.java
1 package org.apidesign.apifest08.currency;
4 * Static exchange rate provider.
8 final class StaticExchangeRateProvider<AmountType, IdentifierType> implements ExchangeRateProvider<AmountType, IdentifierType> {
10 final ExchangeRateValue<AmountType, IdentifierType> exchangeRate;
12 private StaticExchangeRateProvider(ExchangeRateValue<AmountType, IdentifierType> exchangeRate) {
13 this.exchangeRate = exchangeRate;
16 public void getExchangeRate(ExchangeRateRequest<AmountType, IdentifierType> request, ExchangeRateResponse<AmountType, IdentifierType> response) {
17 response.setExchangeRate(exchangeRate);
20 static <AmountType, IdentifierType> StaticExchangeRateProvider<AmountType, IdentifierType> getStaticExchangeRateProvider(ExchangeRateValue<AmountType, IdentifierType> exchangeRate) {
21 return new StaticExchangeRateProvider<AmountType, IdentifierType>(exchangeRate);
25 public boolean equals(Object obj) {
30 if (getClass() != obj.getClass()) {
34 final StaticExchangeRateProvider other = (StaticExchangeRateProvider) obj;
35 if (this.exchangeRate != other.exchangeRate && (this.exchangeRate == null || !this.exchangeRate.equals(other.exchangeRate))) {
43 public int hashCode() {
45 hash = 67 * hash + (this.exchangeRate != null ? this.exchangeRate.hashCode() : 0);