T - the target class implementing MonetaryAmount.public abstract class AbstractAmountFactory<T extends javax.money.MonetaryAmount>
extends java.lang.Object
implements javax.money.MonetaryAmountFactory<T>
MonetaryAmountFactory, which simplifies development of the SPI interface.| Constructor and Description |
|---|
AbstractAmountFactory() |
| Modifier and Type | Method and Description |
|---|---|
T |
create()
Creates a new instance of
MonetaryAmount, using the default MonetaryContext. |
protected abstract T |
create(javax.money.CurrencyUnit currency,
java.lang.Number number,
javax.money.MonetaryContext monetaryContext) |
protected static java.math.BigDecimal |
getBigDecimal(java.lang.Number num)
Creates a
BigDecimal from the given Number doing the valid conversion
depending the type given. |
javax.money.MonetaryContext |
getDefaultMonetaryContext()
Returns the default
MonetaryContext used, when no MonetaryContext is
provided. |
javax.money.MonetaryContext |
getMaximalMonetaryContext()
Returns the maximal
MonetaryContext supported. |
protected abstract javax.money.MonetaryContext |
loadDefaultMonetaryContext() |
protected abstract javax.money.MonetaryContext |
loadMaxMonetaryContext() |
javax.money.MonetaryAmountFactory<T> |
setAmount(javax.money.MonetaryAmount amt)
Converts (if necessary) the given
MonetaryAmount to a new MonetaryAmount
instance, hereby supporting the MonetaryContext given. |
javax.money.MonetaryAmountFactory<T> |
setContext(javax.money.MonetaryContext monetaryContext)
Sets the
MonetaryContext to be used. |
javax.money.MonetaryAmountFactory<T> |
setCurrency(javax.money.CurrencyUnit currency)
Sets the
CurrencyUnit to be used. |
javax.money.MonetaryAmountFactory<T> |
setCurrency(java.lang.String currencyCode)
Sets the
CurrencyUnit to be used. |
javax.money.MonetaryAmountFactory<T> |
setNumber(double number)
Creates a new instance of
MonetaryAmounts, using the default MonetaryContext. |
javax.money.MonetaryAmountFactory<T> |
setNumber(long number)
Sets the number to be used.
|
javax.money.MonetaryAmountFactory<T> |
setNumber(java.lang.Number number)
Sets the number to be used.
|
public T create()
MonetaryAmount, using the default MonetaryContext.create in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>MonetaryAmount combining the numeric value and currency unit.java.lang.ArithmeticException - If the number exceeds the capabilities of the default MonetaryContext
used.MonetaryAmountFactory.getAmountType()protected abstract T create(javax.money.CurrencyUnit currency, java.lang.Number number, javax.money.MonetaryContext monetaryContext)
protected static java.math.BigDecimal getBigDecimal(java.lang.Number num)
BigDecimal from the given Number doing the valid conversion
depending the type given.num - the number typeBigDecimalpublic javax.money.MonetaryContext getDefaultMonetaryContext()
MonetaryContext used, when no MonetaryContext is
provided.getDefaultMonetaryContext in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>MonetaryContext, never null.MonetaryAmountFactory.getMaximalMonetaryContext()public javax.money.MonetaryContext getMaximalMonetaryContext()
MonetaryContext supported.getMaximalMonetaryContext in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>MonetaryContext, never null.protected abstract javax.money.MonetaryContext loadDefaultMonetaryContext()
protected abstract javax.money.MonetaryContext loadMaxMonetaryContext()
public javax.money.MonetaryAmountFactory<T> setAmount(javax.money.MonetaryAmount amt)
MonetaryAmount to a new MonetaryAmount
instance, hereby supporting the MonetaryContext given.setAmount in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>amt - the amount to be converted, if necessary.public javax.money.MonetaryAmountFactory<T> setContext(javax.money.MonetaryContext monetaryContext)
javax.money.MonetaryAmountFactoryMonetaryContext to be used.setContext in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>monetaryContext - the MonetaryContext to be used, not null.MonetaryAmountFactory.getMaximalMonetaryContext()public javax.money.MonetaryAmountFactory<T> setCurrency(javax.money.CurrencyUnit currency)
javax.money.MonetaryAmountFactoryCurrencyUnit to be used.setCurrency in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>currency - the CurrencyUnit to be used, not nullpublic javax.money.MonetaryAmountFactory<T> setCurrency(java.lang.String currencyCode)
javax.money.MonetaryAmountFactoryCurrencyUnit to be used.setCurrency in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>currencyCode - the currencyCode of the currency to be used, not null. The currency code
will be resolved using MonetaryCurrencies.getCurrency(String).public javax.money.MonetaryAmountFactory<T> setNumber(double number)
MonetaryAmounts, using the default MonetaryContext.setNumber in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>number - numeric value.Money combining the numeric value and currency unit.java.lang.ArithmeticException - If the number exceeds the capabilities of the default MonetaryContext
used.javax.money.UnknownCurrencyException - if the currency code can not be resolved to CurrencyUnit.public javax.money.MonetaryAmountFactory<T> setNumber(long number)
javax.money.MonetaryAmountFactorysetNumber in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>number - the number to be usedpublic javax.money.MonetaryAmountFactory<T> setNumber(java.lang.Number number)
javax.money.MonetaryAmountFactorysetNumber in interface javax.money.MonetaryAmountFactory<T extends javax.money.MonetaryAmount>number - the number to be used, not null.