Class RatesConfig.Builder
java.lang.Object
net.thauvin.erik.frankfurter.config.RatesConfig.Builder
- Enclosing class:
- RatesConfig
Builder for creating
RatesConfig instances.
All setter methods return this for method chaining. Call build()
to create the immutable configuration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the base currency.base(CurrencyCode base) Sets the base currency.build()Builds and returns an immutable configuration.Sets a single date for the rate query.Sets the start of a date range query.Sets the grouping period.Sets one or more providers.Sets one or more quote currencies.quotes(CurrencyCode... quotes) Sets one or more quote currencies.Sets the end of a date range query.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
base
Sets the base currency. Optional.If not set, the Frankfurter API defaults to
EUR.- Parameters:
base- the base currency- Returns:
- this builder
- Throws:
NullPointerException- ifbaseisnull
-
base
Sets the base currency. Optional.If not set, the Frankfurter API defaults to
EUR.- Parameters:
base- 3-letter ISO 4217 currency code, e.g. "USD"- Returns:
- this builder
- Throws:
NullPointerException- ifbaseisnullIllegalArgumentException- if blank or not 3 letters
-
build
Builds and returns an immutable configuration.- Returns:
- the immutable config
- Throws:
IllegalArgumentException- if date is combined with from/to, or if to is before fromIllegalStateException- if group is set without a date or date range
-
date
Sets a single date for the rate query.- Parameters:
date- the date to query, must not be before 1994-01-04- Returns:
- this builder
- Throws:
NullPointerException- ifdateisnullIllegalArgumentException- if date is earlier than the minimum supported
-
from
Sets the start of a date range query.- Parameters:
from- the start date, must not be before 1994-01-04- Returns:
- this builder
- Throws:
NullPointerException- iffromisnullIllegalArgumentException- if date is earlier than the minimum supported
-
group
Sets the grouping period.- Parameters:
group- the grouping, e.g. DAY, MONTH, YEAR- Returns:
- this builder
- Throws:
NullPointerException- ifgroupisnull
-
providers
Sets one or more providers.Blank entries are ignored. Duplicates are removed.
- Parameters:
providers- provider IDs, e.g. "ECB", "BANXICO"- Returns:
- this builder
- Throws:
NullPointerException- if array or any element isnull
-
quotes
Sets one or more quote currencies.Blank entries are ignored. Duplicates are removed.
- Parameters:
quotes- 3-letter ISO 4217 currency codes, e.g. "USD", "GBP"- Returns:
- this builder
- Throws:
NullPointerException- if array or any element isnullIllegalArgumentException- if any quote is not 3 letters
-
quotes
Sets one or more quote currencies.Blank entries are ignored. Duplicates are removed.
- Parameters:
quotes- the quote currencies- Returns:
- this builder
- Throws:
NullPointerException- if array or any element isnull
-
to
Sets the end of a date range query.- Parameters:
to- the end date, must not be before 1994-01-04- Returns:
- this builder
- Throws:
NullPointerException- iftoisnullIllegalArgumentException- if date is earlier than the minimum supported
-