public interface MonetaryAmountsSingletonQuerySpi
SPI (core) for the backing implementation of the
Monetary singleton, implementing
the query functionality for amounts.-
Method Summary
Modifier and TypeMethodDescriptionCollection<MonetaryAmountFactory<? extends MonetaryAmount>> Get theMonetaryAmountFactoryimplementation class, that best matches to cover the givenMonetaryContext.default MonetaryAmountFactoryExecutes the query and returns theMonetaryAmountFactoryimplementation type found, if there is only one type.default Class<? extends MonetaryAmount> Executes the query and returns theMonetaryAmountimplementation type found, if there is only one type.default Collection<Class<? extends MonetaryAmount>> Executes the query and returns theMonetaryAmountimplementation types found.default booleanChecks if anMonetaryAmountFactoryis matching the given query.
-
Method Details
-
getAmountFactories
Collection<MonetaryAmountFactory<? extends MonetaryAmount>> getAmountFactories(MonetaryAmountFactoryQuery query) Get theMonetaryAmountFactoryimplementation class, that best matches to cover the givenMonetaryContext.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, aMonetaryExceptionshould 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), theMonetaryAmountimplementation candidate should be chosen with highest possible precision. - If still multiple implementation candidates qualify, the ones with
Flavor.PERFORMANCEare preferred. - After this point the selection may be arbitrary.
- Parameters:
query- the factory query, not null.- Returns:
- the
MonetaryAmountimplementation class, that best matches to cover the givenMonetaryContext, nevernull. - Throws:
MonetaryException- if noMonetaryAmountimplementation class can cover the requiredMonetaryContext.
- If
-
isAvailable
Checks if anMonetaryAmountFactoryis matching the given query.- Parameters:
query- the factory query, not null.- Returns:
- true, if at least one
MonetaryAmountFactorymatches the query.
-
getAmountType
Executes the query and returns theMonetaryAmountimplementation 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 Collection<Class<? extends MonetaryAmount>> getAmountTypes(MonetaryAmountFactoryQuery query) Executes the query and returns theMonetaryAmountimplementation types found.- Parameters:
query- the factory query, not null.- Returns:
- the type found, or null.
-
getAmountFactory
Executes the query and returns theMonetaryAmountFactoryimplementation 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.
-