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