private ExchangeRate constructExchangeRateFromRecord(DatabaseTableRecord record) throws CantCreateExchangeRateException { UUID id = record.getUUIDValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_ID_COLUMN_NAME); double salePrice = record.getDoubleValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_SALE_PRICE_COLUMN_NAME); double purchasePrice = record.getDoubleValue( BitcoinVenezuelaProviderDatabaseConstants .DAILY_EXCHANGE_RATES_PURCHASE_PRICE_COLUMN_NAME); long timestamp = record.getLongValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_TIMESTAMP_COLUMN_NAME); Currency fromCurrency; try { String fromCurrencyStr = record.getStringValue( BitcoinVenezuelaProviderDatabaseConstants .DAILY_EXCHANGE_RATES_FROM_CURRENCY_COLUMN_NAME); if (FiatCurrency.codeExists(fromCurrencyStr)) fromCurrency = FiatCurrency.getByCode(fromCurrencyStr); else if (CryptoCurrency.codeExists(fromCurrencyStr)) fromCurrency = CryptoCurrency.getByCode(fromCurrencyStr); else throw new InvalidParameterException(); } catch (InvalidParameterException e) { throw new CantCreateExchangeRateException( e.getMessage(), e, "BitcoinVenezuela provider plugin", "Invalid From Currency value stored in table" + BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_TABLE_NAME + " for id " + id); } Currency toCurrency; try { String toCurrencyStr = record.getStringValue( BitcoinVenezuelaProviderDatabaseConstants .DAILY_EXCHANGE_RATES_TO_CURRENCY_COLUMN_NAME); if (FiatCurrency.codeExists(toCurrencyStr)) toCurrency = FiatCurrency.getByCode(toCurrencyStr); else if (CryptoCurrency.codeExists(toCurrencyStr)) toCurrency = CryptoCurrency.getByCode(toCurrencyStr); else throw new InvalidParameterException(); } catch (InvalidParameterException e) { throw new CantCreateExchangeRateException( e.getMessage(), e, "BitcoinVenezuela provider plugin", "Invalid To Currency value stored in table" + BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_TABLE_NAME + " for id " + id); } return new ExchangeRateImpl(fromCurrency, toCurrency, salePrice, purchasePrice, timestamp); }