001/**
002 * Copyright (c) 2012, 2014, Credit Suisse (Anatole Tresch), Werner Keil and others by the @author tag.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016package org.javamoney.moneta.internal.convert;
017
018import javax.money.convert.ProviderContext;
019import javax.money.convert.ProviderContextBuilder;
020import javax.money.convert.RateType;
021
022/**
023 * <p>
024 * This class implements an {@link javax.money.convert.ExchangeRateProvider}
025 * that loads data from the European Central Bank data feed (XML). It loads the
026 * current exchange rates, as well as historic rates for the past 90 days. The
027 * provider loads all data up to 1999 into its historic data cache.
028 * </p>
029 * <p>The default date is yesterday or the most recent day of week. To uses exchange rate from a specific date, you can use this way:</p>
030 * <p><code>CurrencyUnit termCurrency = ...;</code></p>
031 * <p><code>LocalDate localDate = ...;</code></p>
032 * <p><code>ConversionQuery conversionQuery = ConversionQueryBuilder.of().setTermCurrency(euro).setTimestamp(localDate).build();</code>v
033 * <p><code>CurrencyConversion currencyConversion = provider.getCurrencyConversion(conversionQuery);</code></p>
034 * <p><code>MonetaryAmount money = ...;</code></p>
035 * <p><code>MonetaryAmount result = currencyConversion.apply(money);</code></p>
036 *
037 * @author Anatole Tresch
038 * @author Werner Keil
039 * @author otaviojava
040 */
041public class ECBHistoric90RateProvider extends ECBAbstractRateProvider {
042
043
044    private static final String DATA_ID = ECBHistoric90RateProvider.class.getSimpleName();
045
046    private static final ProviderContext CONTEXT =
047            ProviderContextBuilder.of("ECB-HIST90", RateType.HISTORIC, RateType.DEFERRED)
048                    .set("providerDescription", "European Central Bank (last 90 days)").set("days", 90).build();
049
050    public ECBHistoric90RateProvider() {
051        super(CONTEXT);
052    }
053
054    @Override
055    public String getDataId() {
056        return DATA_ID;
057    }
058
059
060}