Top Description Methods
javax.money.spi

public Interface MonetaryAmountsSingletonQuerySpi

Imports
javax.money.MonetaryAmount, .MonetaryAmountFactory, .MonetaryAmountFactoryQuery, java.util.Collection, java.util.stream.Collectors

SPI (core) for the backing implementation of the javax.money.Monetary singleton, implementing the query functionality for amounts.
Author
Anatole Tresch

Method Summary

Modifier and TypeMethod and Description
public Collection<MonetaryAmountFactory<? extends MonetaryAmount>>

Returns:

the javax.money.MonetaryAmount implementation class, that best matches to cover the given javax.money.MonetaryContext, never null.
getAmountFactories
(MonetaryAmountFactoryQuery
the factory query, not null.
query
)

Get the javax.money.MonetaryAmountFactory implementation class, that best matches to cover the given javax.money.MonetaryContext.

public default MonetaryAmountFactory<T extends MonetaryAmount>

Returns:

the type found, or null.
getAmountFactory
(MonetaryAmountFactoryQuery
the factory query, not null.
query
)

Executes the query and returns the javax.money.MonetaryAmountFactory implementation type found, if there is only one type.

public default Class<? extends MonetaryAmount>

Returns:

the type found, or null.
getAmountType
(MonetaryAmountFactoryQuery
the factory query, not null.
query
)

Executes the query and returns the javax.money.MonetaryAmount implementation type found, if there is only one type.

public default Collection<Class<? extends MonetaryAmount>>

Returns:

the type found, or null.
getAmountTypes
(MonetaryAmountFactoryQuery
the factory query, not null.
query
)

Executes the query and returns the javax.money.MonetaryAmount implementation types found.

public default boolean

Returns:

true, if at least one javax.money.MonetaryAmountFactory matches the query.
isAvailable
(MonetaryAmountFactoryQuery
the factory query, not null.
query
)

Checks if an javax.money.MonetaryAmountFactory is matching the given query.

Method Detail

getAmountFactoriesback to summary
public Collection<MonetaryAmountFactory<? extends MonetaryAmount>> getAmountFactories(MonetaryAmountFactoryQuery query)

Get the javax.money.MonetaryAmountFactory implementation class, that best matches to cover the given javax.money.MonetaryContext.

The evaluation order should consider the following aspects:

  • If javax.money.MonetaryContext#getAmountType() is explicitly defined, it should be considered. Nevertheless if precision/scale cannot be met, a javax.money.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 javax.money.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:MonetaryAmountFactoryQuery

the factory query, not null.

Returns:Collection<MonetaryAmountFactory<? extends MonetaryAmount>>

the javax.money.MonetaryAmount implementation class, that best matches to cover the given javax.money.MonetaryContext, never null.

Exceptions
MonetaryException:
if no javax.money.MonetaryAmount implementation class can cover the required javax.money.MonetaryContext.
getAmountFactoryback to summary
public default MonetaryAmountFactory<T extends MonetaryAmount> getAmountFactory(MonetaryAmountFactoryQuery query)

Executes the query and returns the javax.money.MonetaryAmountFactory implementation type found, if there is only one type. If multiple types match the query, the first one is selected.

Parameters
query:MonetaryAmountFactoryQuery

the factory query, not null.

Returns:MonetaryAmountFactory<T extends MonetaryAmount>

the type found, or null.

Annotations
@SuppressWarnings:rawtypes
getAmountTypeback to summary
public default Class<? extends MonetaryAmount> getAmountType(MonetaryAmountFactoryQuery query)

Executes the query and returns the javax.money.MonetaryAmount implementation type found, if there is only one type. If multiple types match the query, the first one is selected.

Parameters
query:MonetaryAmountFactoryQuery

the factory query, not null.

Returns:Class<? extends MonetaryAmount>

the type found, or null.

getAmountTypesback to summary
public default Collection<Class<? extends MonetaryAmount>> getAmountTypes(MonetaryAmountFactoryQuery query)

Executes the query and returns the javax.money.MonetaryAmount implementation types found.

Parameters
query:MonetaryAmountFactoryQuery

the factory query, not null.

Returns:Collection<Class<? extends MonetaryAmount>>

the type found, or null.

isAvailableback to summary
public default boolean isAvailable(MonetaryAmountFactoryQuery query)

Checks if an javax.money.MonetaryAmountFactory is matching the given query.

Parameters
query:MonetaryAmountFactoryQuery

the factory query, not null.

Returns:boolean

true, if at least one javax.money.MonetaryAmountFactory matches the query.