Skip to content

Commit 9001b71

Browse files
committed
3: Create new ExchangeRateProvider implementations for Bitcoin
Task-Url: http://github.com/JavaMoney/javamoney-shelter/issues/issue/3
1 parent ea1a7be commit 9001b71

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

digital-currency/bitcoin/src/main/java/org/javamoney/shelter/bitcoin/provider/BitcoinDeRateProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private SupportedCurrency(String code) {
7272
this.currencyCode = code;
7373
}
7474

75-
public static boolean isSupported(String newCurrency) {
75+
public static boolean contains(String newCurrency) {
7676
try {
7777
valueOf(newCurrency);
7878
} catch (IllegalArgumentException e) {
@@ -84,7 +84,7 @@ public static boolean isSupported(String newCurrency) {
8484

8585
private final String forCurrency;
8686

87-
private Map<String, Number> currentRates = new ConcurrentHashMap<String, Number>();
87+
private final Map<String, Number> currentRates = new ConcurrentHashMap<>();
8888

8989
public BitcoinDeRateProvider() {
9090
this(null);
@@ -121,12 +121,12 @@ public ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term, long t
121121

122122
@Override
123123
public ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term) {
124-
if (!SupportedCurrency.isSupported(base.getCurrencyCode()) || SupportedCurrency.isSupported(term.getCurrencyCode())) {
124+
if (!SupportedCurrency.contains(base.getCurrencyCode()) || SupportedCurrency.contains(term.getCurrencyCode())) {
125125
return null;
126126
}
127127
final NumberValue factor = DefaultNumberValue.of(currentRates.get(base.getCurrencyCode()));
128128
if (factor!=null) {
129-
return new ExchangeRate.Builder("MtGox", RATE_TYPE).setBase(base).setTerm(term).setFactor(factor).create();
129+
return new ExchangeRate.Builder("Bitcoin.de", RATE_TYPE).setBase(base).setTerm(term).setFactor(factor).create();
130130
} else {
131131
return null;
132132
}
@@ -136,7 +136,7 @@ public ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term) {
136136
* Looks up the rate for a given currencyCode
137137
*/
138138
void loadRate(String curCode, boolean verbose) {
139-
if (SupportedCurrency.isSupported(curCode)) {
139+
if (SupportedCurrency.contains(curCode)) {
140140
ObjectMapper m = new ObjectMapper();
141141
JsonNode root;
142142
try {

0 commit comments

Comments
 (0)