Module java.money

Interface MonetaryAmountsSingletonQuerySpi


  • public interface MonetaryAmountsSingletonQuerySpi
    SPI (core) for the backing implementation of the Monetary singleton, implementing the query functionality for amounts.
    Author:
    Anatole Tresch
    • Method Detail

      • getAmountFactories

        java.util.Collection<MonetaryAmountFactory<? extends MonetaryAmount>> getAmountFactories​(MonetaryAmountFactoryQuery query)
        Get the MonetaryAmountFactory implementation class, that best matches to cover the given MonetaryContext.

        The evaluation order should consider the following aspects:

        • If MonetaryContext.getAmountType() is explicitly defined, it should be considered. Nevertheless if precision/scale cannot be met, a MonetaryException should be thrown.
        • The remaining implementation class candidates must cover the required precision.
        • The remaining implementation class candidates must cover the required max scale.
        • If max scale is met, but precision==0 (unlimited precision), the MonetaryAmount implementation candidate should be chosen with highest possible precision.
        • If still multiple implementation candidates qualify, the ones with Flavor.PERFORMANCE are preferred.
        • After this point the selection may be arbitrary.
        Parameters:
        query - the factory query, not null.
        Returns:
        the MonetaryAmount implementation class, that best matches to cover the given MonetaryContext, never null.
        Throws:
        MonetaryException - if no MonetaryAmount implementation class can cover the required MonetaryContext.
      • getAmountType

        default java.lang.Class<? extends MonetaryAmount> getAmountType​(MonetaryAmountFactoryQuery query)
        Executes the query and returns the MonetaryAmount implementation type found, if there is only one type. If multiple types match the query, the first one is selected.
        Parameters:
        query - the factory query, not null.
        Returns:
        the type found, or null.
      • getAmountTypes

        default java.util.Collection<java.lang.Class<? extends MonetaryAmount>> getAmountTypes​(MonetaryAmountFactoryQuery query)
        Executes the query and returns the MonetaryAmount implementation types found.
        Parameters:
        query - the factory query, not null.
        Returns:
        the type found, or null.
      • getAmountFactory

        default MonetaryAmountFactory getAmountFactory​(MonetaryAmountFactoryQuery query)
        Executes the query and returns the MonetaryAmountFactory implementation type found, if there is only one type. If multiple types match the query, the first one is selected.
        Parameters:
        query - the factory query, not null.
        Returns:
        the type found, or null.