Top Description Fields Constructors Methods
org.javamoney.moneta.spi

public abstract Class AbstractAmountFactory<T extends MonetaryAmount>

extends Object
implements MonetaryAmountFactory<T extends MonetaryAmount>
Class Inheritance
All Implemented Interfaces
javax.money.MonetaryAmountFactory
Known Direct Subclasses
org.javamoney.moneta.spi.FastMoneyAmountFactory, org.javamoney.moneta.spi.MoneyAmountFactory, org.javamoney.moneta.spi.RoundedMoneyAmountFactory
Type Parameters
<T>
the target class implementing javax.money.MonetaryAmount.
Imports
javax.money.*, java.math.BigDecimal, java.util.Objects

Basic implementation of javax.money.MonetaryAmountFactory, which simplifies development of the SPI interface.

Field Summary

Modifier and TypeField and Description
private CurrencyUnit
private final MonetaryContext
defaultMonetaryContext

The default MonetaryContext applied, if not set explicitly on creation.

private final MonetaryContext
maxMonetaryContext

The default MonetaryContext applied, if not set explicitly on creation.

private MonetaryContext
private Number

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

a MonetaryAmount combining the numeric value and currency unit.
create
()

Implements javax.money.MonetaryAmountFactory.create.

Creates a new instance of MonetaryAmount, using the default MonetaryContext.

protected abstract T
create(Number number, CurrencyUnit currency, MonetaryContext monetaryContext)

protected static BigDecimal

Returns:

the corresponding BigDecimal
getBigDecimal
(Number
the number type
num
)
Deprecated will be removed in next release

Creates a BigDecimal from the given Number doing the valid conversion depending the type given.

public MonetaryContext

Returns:

the default MonetaryContext, never null.
getDefaultMonetaryContext
()

Implements javax.money.MonetaryAmountFactory.getDefaultMonetaryContext.

Returns the default MonetaryContext used, when no MonetaryContext is provided.

public MonetaryContext

Returns:

the maximal MonetaryContext, never null.
getMaximalMonetaryContext
()

Overrides default javax.money.MonetaryAmountFactory.getMaximalMonetaryContext.

Returns the maximal MonetaryContext supported.

protected abstract MonetaryContext
protected abstract MonetaryContext
public MonetaryAmountFactory<T>

Returns:

an according Money instance.
setAmount
(MonetaryAmount
the amount to be converted, if necessary.
smount
)

Overrides default javax.money.MonetaryAmountFactory.setAmount.

Converts (if necessary) the given MonetaryAmount to a new MonetaryAmount instance, hereby supporting the MonetaryContext given.

public MonetaryAmountFactory<T>
public MonetaryAmountFactory<T>
public MonetaryAmountFactory<T>
setCurrency(String currencyCode)

Overrides default javax.money.MonetaryAmountFactory.setCurrency.

Sets the CurrencyUnit to be used.

public MonetaryAmountFactory<T>
setNumber(Number number)

Implements javax.money.MonetaryAmountFactory.setNumber.

Sets the number to be used.

public MonetaryAmountFactory<T>

Returns:

a Money combining the numeric value and currency unit.
setNumber
(double
numeric value.
number
)

Implements javax.money.MonetaryAmountFactory.setNumber.

Creates a new instance of Monetary, using the default MonetaryContext.

public MonetaryAmountFactory<T>
setNumber(long number)

Implements javax.money.MonetaryAmountFactory.setNumber.

Sets the number to be used.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currencyback to summary
private CurrencyUnit currency
defaultMonetaryContextback to summary
private final MonetaryContext defaultMonetaryContext

The default MonetaryContext applied, if not set explicitly on creation.

maxMonetaryContextback to summary
private final MonetaryContext maxMonetaryContext

The default MonetaryContext applied, if not set explicitly on creation.

monetaryContextback to summary
private MonetaryContext monetaryContext
numberback to summary
private Number number

Constructor Detail

AbstractAmountFactoryback to summary
public AbstractAmountFactory()

Method Detail

createback to summary
public T create()

Implements javax.money.MonetaryAmountFactory.create.

Creates a new instance of MonetaryAmount, using the default MonetaryContext.

Returns:T

a MonetaryAmount combining the numeric value and currency unit.

Annotations
@Override
Exceptions
ArithmeticException:
If the number exceeds the capabilities of the default MonetaryContext used.
createback to summary
protected abstract T create(Number number, CurrencyUnit currency, MonetaryContext monetaryContext)
getBigDecimalback to summary
protected static BigDecimal getBigDecimal(Number num)

Deprecated

will be removed in next release

Creates a BigDecimal from the given Number doing the valid conversion depending the type given.

Parameters
num:Number

the number type

Returns:BigDecimal

the corresponding BigDecimal

Annotations
@Deprecated
getDefaultMonetaryContextback to summary
public MonetaryContext getDefaultMonetaryContext()

Implements javax.money.MonetaryAmountFactory.getDefaultMonetaryContext.

Returns the default MonetaryContext used, when no MonetaryContext is provided.

Returns:MonetaryContext

the default MonetaryContext, never null.

Annotations
@Override
getMaximalMonetaryContextback to summary
public MonetaryContext getMaximalMonetaryContext()

Overrides default javax.money.MonetaryAmountFactory.getMaximalMonetaryContext.

Returns the maximal MonetaryContext supported.

Returns:MonetaryContext

the maximal MonetaryContext, never null.

Annotations
@Override
loadDefaultMonetaryContextback to summary
protected abstract MonetaryContext loadDefaultMonetaryContext()
loadMaxMonetaryContextback to summary
protected abstract MonetaryContext loadMaxMonetaryContext()
setAmountback to summary
public MonetaryAmountFactory<T> setAmount(MonetaryAmount smount)

Overrides default javax.money.MonetaryAmountFactory.setAmount.

Converts (if necessary) the given MonetaryAmount to a new MonetaryAmount instance, hereby supporting the MonetaryContext given.

Parameters
smount:MonetaryAmount

the amount to be converted, if necessary.

Returns:MonetaryAmountFactory<T>

an according Money instance.

Annotations
@Override
setContextback to summary
public MonetaryAmountFactory<T> setContext(MonetaryContext monetaryContext)

Implements javax.money.MonetaryAmountFactory.setContext.

Doc from javax.money.MonetaryAmountFactory.setContext.

Sets the MonetaryContext to be used.

Annotations
@Override
setCurrencyback to summary
public MonetaryAmountFactory<T> setCurrency(CurrencyUnit currency)

Implements javax.money.MonetaryAmountFactory.setCurrency.

Doc from javax.money.MonetaryAmountFactory.setCurrency.

Sets the CurrencyUnit to be used.

Annotations
@Override
setCurrencyback to summary
public MonetaryAmountFactory<T> setCurrency(String currencyCode)

Overrides default javax.money.MonetaryAmountFactory.setCurrency.

Doc from javax.money.MonetaryAmountFactory.setCurrency.

Sets the CurrencyUnit to be used.

Annotations
@Override
setNumberback to summary
public MonetaryAmountFactory<T> setNumber(Number number)

Implements javax.money.MonetaryAmountFactory.setNumber.

Doc from javax.money.MonetaryAmountFactory.setNumber.

Sets the number to be used.

Annotations
@Override
setNumberback to summary
public MonetaryAmountFactory<T> setNumber(double number)

Implements javax.money.MonetaryAmountFactory.setNumber.

Creates a new instance of Monetary, using the default MonetaryContext.

Parameters
number:double

numeric value.

Returns:MonetaryAmountFactory<T>

a Money combining the numeric value and currency unit.

Annotations
@Override
Exceptions
ArithmeticException:
If the number exceeds the capabilities of the default MonetaryContext used.
UnknownCurrencyException:
if the currency code can not be resolved to CurrencyUnit.
setNumberback to summary
public MonetaryAmountFactory<T> setNumber(long number)

Implements javax.money.MonetaryAmountFactory.setNumber.

Doc from javax.money.MonetaryAmountFactory.setNumber.

Sets the number to be used.

Annotations
@Override