Top Description Fields Constructors Methods
org.javamoney.moneta

public final Class CurrencyUnitBuilder

extends Object
Class Inheritance
Imports
org.javamoney.moneta.spi.ConfigurableCurrencyUnitProvider, javax.money.CurrencyContextBuilder, .CurrencyUnit, .CurrencyContext, java.util.Locale, .Objects

Builder for constructing new instances of BuildableCurrencyUnit using a fluent API.

Field Summary

Modifier and TypeField and Description
pack-priv String
currencyCode

The currency code.

pack-priv CurrencyContext
currencyContext

The currency's context.

pack-priv int
defaultFractionDigits

The default fraction digits.

pack-priv int
numericCode

The (optional) numeric code.

Constructor Summary

AccessConstructor and Description
private
CurrencyUnitBuilder()

Private constructor, use #of() methods.

private
CurrencyUnitBuilder(String
the (unique) and identifying currency code, not null.
currencyCode
,
CurrencyContext currencyContext)

Creates a new Builder.

Method Summary

Modifier and TypeMethod and Description
public CurrencyUnit

Returns:

the new CurrencyUnit instance.
build
()

Returns a new instance of BuildableCurrencyUnit.

public CurrencyUnit

Returns:

the new CurrencyUnit instance.
build
(boolean
if true the instance created is published so it is accessible from the Monetary singleton.
register
)

Returns a new instance of BuildableCurrencyUnit and publishes it so it is accessible from the Monetary singleton.

public CurrencyUnit

Returns:

the new CurrencyUnit instance.
build
(boolean
if true the instance created is published so it is accessible from the Monetary singleton.
register
,
Locale
country Locale for making the currency for the given country.
locale
)

Returns a new instance of BuildableCurrencyUnit and publishes it so it is accessible from the Monetary singleton.

public static CurrencyUnitBuilder
of(String
the (unique) and identifying currency code, not null.
currencyCode
,
CurrencyContext
The currency context to be used.
currencyContext
)

Creates a new CurrencyUnitBuilder.

public static CurrencyUnitBuilder
of(String
the (unique) and identifying currency code, not null.
currencyCode
,
String
the currency provider, not null.
providerName
)

Creates a new CurrencyUnitBuilder, creates a simple CurrencyContext using the given provider name.

public CurrencyUnitBuilder

Returns:

the Builder, for chaining.
setCurrencyCode
(String
the (unique) and identifying currency code, not null.
currencyCode
)

Allows to set the currency code, for creating multiple instances, using one Builder.

public CurrencyUnitBuilder

Returns:

the Builder, for chaining.
setDefaultFractionDigits
(int
the default fraction digits, >= 0.
defaultFractionDigits
)

Set the default fraction digits.

public CurrencyUnitBuilder

Returns:

the Builder, for chaining.
setNumericCode
(int
The numeric currency code, >= -1. .1 hereby means undefined.
numericCode
)

Set the numeric code (optional).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currencyCodeback to summary
pack-priv String currencyCode

The currency code.

currencyContextback to summary
pack-priv CurrencyContext currencyContext

The currency's context.

defaultFractionDigitsback to summary
pack-priv int defaultFractionDigits

The default fraction digits.

numericCodeback to summary
pack-priv int numericCode

The (optional) numeric code.

Constructor Detail

CurrencyUnitBuilderback to summary
private CurrencyUnitBuilder()

Private constructor, use #of() methods.

CurrencyUnitBuilderback to summary
private CurrencyUnitBuilder(String currencyCode, CurrencyContext currencyContext)

Creates a new Builder.

Parameters
currencyCode:String

the (unique) and identifying currency code, not null.

Method Detail

buildback to summary
public CurrencyUnit build()

Returns a new instance of BuildableCurrencyUnit.

Returns:CurrencyUnit

the new CurrencyUnit instance.

Exceptions
MonetaryException:
if creation fails
buildback to summary
public CurrencyUnit build(boolean register)

Returns a new instance of BuildableCurrencyUnit and publishes it so it is accessible from the Monetary singleton.

Parameters
register:boolean

if true the instance created is published so it is accessible from the Monetary singleton.

Returns:CurrencyUnit

the new CurrencyUnit instance.

See Also
javax.money.Monetary#getCurrency(String, String...)
buildback to summary
public CurrencyUnit build(boolean register, Locale locale)

Returns a new instance of BuildableCurrencyUnit and publishes it so it is accessible from the Monetary singleton.

Parameters
register:boolean

if true the instance created is published so it is accessible from the Monetary singleton.

locale:Locale

country Locale for making the currency for the given country.

Returns:CurrencyUnit

the new CurrencyUnit instance.

See Also
javax.money.Monetary#getCurrency(String, String...), javax.money.Monetary#getCurrency(java.util.Locale, String...)
ofback to summary
public static CurrencyUnitBuilder of(String currencyCode, CurrencyContext currencyContext)

Creates a new CurrencyUnitBuilder.

Parameters
currencyCode:String

the (unique) and identifying currency code, not null.

currencyContext:CurrencyContext

The currency context to be used.

ofback to summary
public static CurrencyUnitBuilder of(String currencyCode, String providerName)

Creates a new CurrencyUnitBuilder, creates a simple CurrencyContext using the given provider name.

Parameters
currencyCode:String

the (unique) and identifying currency code, not null.

providerName:String

the currency provider, not null.

setCurrencyCodeback to summary
public CurrencyUnitBuilder setCurrencyCode(String currencyCode)

Allows to set the currency code, for creating multiple instances, using one Builder.

Parameters
currencyCode:String

the (unique) and identifying currency code, not null.

Returns:CurrencyUnitBuilder

the Builder, for chaining.

See Also
javax.money.CurrencyUnit#getCurrencyCode()
setDefaultFractionDigitsback to summary
public CurrencyUnitBuilder setDefaultFractionDigits(int defaultFractionDigits)

Set the default fraction digits.

Parameters
defaultFractionDigits:int

the default fraction digits, >= 0.

Returns:CurrencyUnitBuilder

the Builder, for chaining.

See Also
javax.money.CurrencyUnit#getDefaultFractionDigits()
setNumericCodeback to summary
public CurrencyUnitBuilder setNumericCode(int numericCode)

Set the numeric code (optional).

Parameters
numericCode:int

The numeric currency code, >= -1. .1 hereby means undefined.

Returns:CurrencyUnitBuilder

the Builder, for chaining.

See Also
javax.money.CurrencyUnit#getNumericCode()