001/**
002 * Copyright (c) 2012, 2015, 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.convert;
017
018import javax.money.convert.ExchangeRateProviderSupplier;
019
020import org.javamoney.moneta.internal.convert.ECBCurrentRateProvider;
021import org.javamoney.moneta.internal.convert.ECBHistoric90RateProvider;
022import org.javamoney.moneta.internal.convert.ECBHistoricRateProvider;
023import org.javamoney.moneta.internal.convert.IMFHistoricRateProvider;
024import org.javamoney.moneta.internal.convert.IMFRateProvider;
025import org.javamoney.moneta.internal.convert.IdentityRateProvider;
026
027/**
028 * <p>
029 * This enum contains all implementations by Moneta. Using this enum will easier
030 * to choose an available implementation.
031 * </p>
032 * <code>ExchangeRateProvider provider = MonetaryConversions.getExchangeRateProvider(ExchangeRateType.ECB);<code>
033 * @author otaviojava
034 * @author Werner Keil
035 * @since 1.0.1
036 */
037public enum ExchangeRateType implements ExchangeRateProviderSupplier {
038    /**
039     * Exchange rate to the European Central Bank. Uses the
040     * {@link ECBCurrentRateProvider} implementation.
041     */
042    ECB("ECB", "Exchange rate to the European Central Bank."),
043    /**
044     * Exchange rate to the International Monetary Fond. Uses the
045     * {@link IMFRateProvider} implementation.
046     */
047    IMF("IMF", "Exchange rate to the International Monetary Fond."),
048    /**
049     * Exchange rate to the International Monetary Fond from historic. Uses the
050     * {@link IMFHistoricRateProvider} implementation.
051     */
052    IMF_HIST("IMF-HIST", "Exchange rate to the International Monetary Fond that retrieve historical information on lazy way."),
053    /**
054     * Exchange rate to European Central Bank (last 90 days). Uses the
055     * {@link ECBHistoric90RateProvider} implementation.
056     */
057    ECB_HIST90("ECB-HIST90",
058            "Exchange rate to European Central Bank (last 90 days)."),
059    /**
060     * Uses the {@link ECBHistoricRateProvider} implementation.
061     */
062    ECB_HIST(
063            "ECB-HIST",
064            "Exchange rate to the European Central Bank that loads all data up to 1999 into its historic data cache."),
065    /**
066     * Uses the {@link IdentityRateProvider} implementation.
067     */
068    IDENTITY(
069            "IDENT",
070            "Exchange rate rate with factor one for identical base/term currencies");
071
072    private final String type;
073
074    private final String description;
075
076    ExchangeRateType(String type, String description) {
077        this.type = type;
078        this.description = description;
079    }
080
081    @Override
082    public String get() {
083        return type;
084    }
085
086    public String getDescription() {
087        return description;
088    }
089}