MonetaryAmount instances for a given type. It can be accessed, by
MonetaryAmount#getFactory(), returning a MonetaryAmountFactory
creating amounts of the same implementation type, which also provided the factory instance.Monetary#getAmountFactory(Class) accessing a
MonetaryAmountFactory for a concrete type Class<T>.Monetary#getDefaultAmountFactory() accessing a default
MonetaryAmountFactory.
Implementations of this interface allow to get MonetaryAmount instances providing
different data as required:
CurrencyUnit, or the corresponding currency code (must be solvable by
Monetary).MonetaryContextMonetaryAmount 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.MonetaryContext is used, which can also be configured by adding
configuration to a file /javamoney.properties 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).| Modifier and Type | Method and Description |
|---|---|
| public T | Returns: the correspondingMonetaryAmount.Creates a new instance of |
| public Class | |
| public MonetaryContext | getDefaultMonetaryContext()
Returns the default |
| public default MonetaryContext | getMaximalMonetaryContext()
Returns the maximal |
| public NumberValue | Returns: the maximum possible number, or null.Get the maximum possible number that this type can represent. |
| public NumberValue | Returns: the minimum possible number, or null.Get the minimum possible number that this type can represent. |
| public default MonetaryAmountFactory | Returns: this factory instance, for chaining.the amount to be used, not amount)null.Uses an arbitrary |
| public MonetaryAmountFactory | Returns: This factory instance, for chaining.the monetaryContext)MonetaryContext to be used, not null.Sets the |
| public default MonetaryAmountFactory | Returns: This factory instance, for chaining.the currencyCode of the currency to be used, not currencyCode)null. The currency code
will be resolved using Monetary#getCurrency(String, String...).Sets the |
| public MonetaryAmountFactory | Returns: This factory instance, for chaining.the currency)CurrencyUnit to be used, not nullSets the |
| public MonetaryAmountFactory | Returns: This factory instance, for chaining.the number to be used number)Sets the number to be used. |
| public MonetaryAmountFactory | Returns: This factory instance, for chaining.the number to be used number)Sets the number to be used. |
| public MonetaryAmountFactory |
| create | back to summary |
|---|---|
| public T create() Creates a new instance of
| |
| getAmountType | back to summary |
|---|---|
| public Class Access the
| |
| getDefaultMonetaryContext | back to summary |
|---|---|
| public MonetaryContext getDefaultMonetaryContext() Returns the default
The default context is not allowed to exceed the capabilities of the maximal
| |
| getMaximalMonetaryContext | back to summary |
|---|---|
| public default MonetaryContext getMaximalMonetaryContext() Returns the maximal
| |
| getMaxNumber | back to summary |
|---|---|
| public NumberValue getMaxNumber() Get the maximum possible number that this type can represent. If the numeric model has no limitations on the
numeric range, null should be returned. If
| |
| getMinNumber | back to summary |
|---|---|
| public NumberValue getMinNumber() Get the minimum possible number that this type can represent. If the numeric model has no limitations on the
numeric range, null should be returned. If
| |
| setAmount | back to summary |
|---|---|
| public default MonetaryAmountFactory Uses an arbitrary
| |
| setContext | back to summary |
|---|---|
| public MonetaryAmountFactory Sets the
| |
| setCurrency | back to summary |
|---|---|
| public default MonetaryAmountFactory Sets the
| |
| setCurrency | back to summary |
|---|---|
| public MonetaryAmountFactory Sets the
| |
| setNumber | back to summary |
|---|---|
| public MonetaryAmountFactory Sets the number to be used.
| |
| setNumber | back to summary |
|---|---|
| public MonetaryAmountFactory Sets the number to be used.
| |
| setNumber | back to summary |
|---|---|
| public MonetaryAmountFactory Sets the number to be used.
| |