public abstract class BaseMonetaryAmountFactory<T extends MonetaryAmount> extends Object implements MonetaryAmountFactory<T>
MonetaryAmount instances for a given type. It can be accessed, by
MonetaryAmount.getFactory(), returning a BaseMonetaryAmountFactory
creating amounts of the same implementation type, which also provided the factory instance.Monetary.getAmountFactory(Class) accessing a
BaseMonetaryAmountFactory for a concrete type Class<T>.Monetary.getDefaultAmountFactory() accessing a default
BaseMonetaryAmountFactory.
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).| Constructor and Description |
|---|
BaseMonetaryAmountFactory() |
| Modifier and Type | Method and Description |
|---|---|
MonetaryContext |
getMaximalMonetaryContext()
Returns the maximal
MonetaryContext supported, for requests that exceed these maximal
capabilities, an ArithmeticException must be thrown. |
MonetaryAmountFactory<T> |
setAmount(MonetaryAmount amount)
Uses an arbitrary
MonetaryAmount to initialize this factory. |
MonetaryAmountFactory<T> |
setCurrency(String currencyCode)
Sets the
CurrencyUnit to be used. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, getAmountType, getDefaultMonetaryContext, getMaxNumber, getMinNumber, setContext, setCurrency, setNumber, setNumber, setNumberpublic BaseMonetaryAmountFactory()
public MonetaryAmountFactory<T> setCurrency(String currencyCode)
CurrencyUnit to be used.setCurrency in interface MonetaryAmountFactory<T extends MonetaryAmount>currencyCode - the currencyCode of the currency to be used, not null. The currency code
will be resolved using Monetary.getCurrency(String, String...).UnknownCurrencyException - if the currencyCode is not resolvable.UnknownCurrencyException - if the currencyCode is not resolvable.public MonetaryAmountFactory<T> setAmount(MonetaryAmount amount)
MonetaryAmount to initialize this factory. Properties reused are:
setAmount in interface MonetaryAmountFactory<T extends MonetaryAmount>amount - the amount to be used, not null.MonetaryException - when the MonetaryContext implied by amount.getContext()
exceeds the capabilities supported by this factory type.public MonetaryContext getMaximalMonetaryContext()
MonetaryContext supported, for requests that exceed these maximal
capabilities, an ArithmeticException must be thrown.getMaximalMonetaryContext in interface MonetaryAmountFactory<T extends MonetaryAmount>MonetaryContext supported, never nullCopyright © 2012–2020 JavaMoney. All rights reserved.