java.lang.Object
javax.money.AbstractContextBuilder<ProviderContextBuilder,ProviderContext>
javax.money.convert.ProviderContextBuilder
public final class ProviderContextBuilder extends AbstractContextBuilder<ProviderContextBuilder,ProviderContext>
Builder class to of
ProviderContext
instances. Instances of
this class are not thread-safe.- Author:
- Anatole Tresch
-
Method Summary
Modifier and Type Method Description ProviderContext
build()
Creates a newProviderContext
with the data from this Builder instance.static ProviderContextBuilder
create(ProviderContext context)
Create a new ProviderContextBuilder, hereby using the givenProviderContext
's values as defaults.static ProviderContextBuilder
of(java.lang.String provider, java.util.Collection<RateType> rateTypes)
Create a new ProviderContextBuilder instance.static ProviderContextBuilder
of(java.lang.String provider, RateType rateType, RateType... rateTypes)
Create a new ProviderContextBuilder instance.ProviderContextBuilder
setRateTypes(java.util.Collection<RateType> rateTypes)
Set the rate types.ProviderContextBuilder
setRateTypes(RateType... rateTypes)
Set the rate types.Methods inherited from class javax.money.AbstractContextBuilder
importContext, importContext, removeAttributes, set, set, set, set, set, set, set, set, set, setProviderName, toString
-
Method Details
-
setRateTypes
Set the rate types.- Parameters:
rateTypes
- the rate types, not null and not empty.- Returns:
- this, for chaining.
- Throws:
java.lang.IllegalArgumentException
- when not at least oneRateType
is provided.
-
setRateTypes
Set the rate types.- Parameters:
rateTypes
- the rate types, not null and not empty.- Returns:
- this, for chaining.
- Throws:
java.lang.IllegalArgumentException
- when not at least oneRateType
is provided.
-
build
Creates a newProviderContext
with the data from this Builder instance.- Specified by:
build
in classAbstractContextBuilder<ProviderContextBuilder,ProviderContext>
- Returns:
- a new
ProviderContext
. nevernull
.
-
create
Create a new ProviderContextBuilder, hereby using the givenProviderContext
's values as defaults. This allows changing an existingProviderContext
easily.- Parameters:
context
- the context, notnull
- Returns:
- a new
ProviderContextBuilder
instance, never null.
-
of
public static ProviderContextBuilder of(java.lang.String provider, RateType rateType, RateType... rateTypes)Create a new ProviderContextBuilder instance.- Parameters:
provider
- the provider name, notnull
.rateType
- the requiredRateType
, not nullrateTypes
- the rate types, not null and not empty.- Returns:
- a new
ProviderContextBuilder
instance, never null.
-
of
public static ProviderContextBuilder of(java.lang.String provider, java.util.Collection<RateType> rateTypes)Create a new ProviderContextBuilder instance.- Parameters:
provider
- the provider name, notnull
.rateTypes
- the rate types, not null and not empty.- Returns:
- a new
ProviderContextBuilder
instance, never null.
-