/* (non-Javadoc) * @see com.ning.billing.catalog.IInternationalPrice#getPrice(com.ning.billing.catalog.api.Currency) */ @Override public BigDecimal getPrice(Currency currency) throws CatalogApiException { for (Price p : prices) { if (p.getCurrency() == currency) { return p.getValue(); } } throw new CatalogApiException(ErrorCode.CAT_NO_PRICE_FOR_CURRENCY, currency); }
@Override public ValidationErrors validate(StandaloneCatalog catalog, ValidationErrors errors) { Currency[] supportedCurrencies = catalog.getCurrentSupportedCurrencies(); for (Price p : prices) { Currency currency = p.getCurrency(); if (!currencyIsSupported(currency, supportedCurrencies)) { errors.add( "Unsupported currency: " + currency, catalog.getCatalogURI(), this.getClass(), ""); } try { if (p.getValue().doubleValue() < 0.0) { errors.add( "Negative value for price in currency: " + currency, catalog.getCatalogURI(), this.getClass(), ""); } } catch (CurrencyValueNull e) { // No currency => nothing to check, ignore exception } } return errors; }