001/*
002 * CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE
003 * CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT.
004 * PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY
005 * DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THE
006 * AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE"
007 * BUTTON AT THE BOTTOM OF THIS PAGE.
008 * 
009 * Specification: JSR-354 Money and Currency API ("Specification")
010 * 
011 * Copyright (c) 2012-2014, Credit Suisse All rights reserved.
012 */
013package org.javamoney.moneta.spi.base;
014
015import javax.money.CurrencyQuery;
016import javax.money.spi.CurrencyProviderSpi;
017
018/**
019 * SPI (core) to be registered using the {@link javax.money.spi.Bootstrap}, which allows to
020 * register/provide additional currencies into the system automatically on
021 * startup. The implementation is allowed to be implemented in y contextual way,
022 * so depending on the runtime context, different currencies may be available.
023 *
024 * @author Anatole Tresch
025 */
026public abstract class BaseCurrencyProviderSpi implements CurrencyProviderSpi{
027
028
029    /**
030     * The unique name of this currency provider instance.
031     * @return hte unique provider id, never null or empty.
032     */
033    public String getProviderName(){
034        return getClass().getSimpleName();
035    }
036
037    /**
038     * CHecks if a {@link javax.money.CurrencyUnit} instances matching the given
039     * {@link javax.money.CurrencyContext} is available from this provider.
040     *
041     * @param query the {@link javax.money.CurrencyQuery} containing the parameters determining the query. not null.
042     * @return false, if no such unit is provided by this provider.
043     */
044    public boolean isCurrencyAvailable(CurrencyQuery query){
045        return !getCurrencies(query).isEmpty();
046    }
047
048}