Interface MonetaryAmountFactory<T extends MonetaryAmount>

public interface MonetaryAmountFactory<T extends MonetaryAmount>
Factory for MonetaryAmount instances for a given type. It can be accessed, by

Implementations of this interface allow to get MonetaryAmount instances providing different data as required:

  • the CurrencyUnit, or the corresponding currency code (must be solvable by Monetary).
  • the number part
  • the MonetaryContext
  • by passing any MonetaryAmount instance, it is possible to convert an arbitrary amount implementation to the implementation provided by this factory. If the current factory cannot support the precision/scale as required by the current NumberValue a MonetaryException must be thrown.
If not defined a default MonetaryContext is used, which can also be configured by adding configuration to a file / to the classpath.

Hereby the entries. e.g. for a class MyMoney should start with a.b.MyMoney.ctx. The entries valid must be documented on the according implementation class, where the following entries are defined for all implementation types (example below given for a class a.b.MyMoney:

  • a.b.MyMoney.ctx.precision to define the maximal supported precision.
  • a.b.MyMoney.ctx.maxScale to define the maximal supported scale.
  • a.b.MyMoney.ctx.fixedScale to define the scale to be fixed (constant).

Implementation specification

Instances of this interface are not required to be thread-safe!
Anatole Tresch, Werner Keil