Package net.thauvin.erik.frankfurter
Class LatestRates.Builder
java.lang.Object
net.thauvin.erik.frankfurter.LatestRates.Builder
- Enclosing class:
- LatestRates
Builder class to construct instances of the
LatestRates class.
This class allows incremental configuration of the LatestRates object via method chaining.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionamount(int amount) Sets the amount for the builder.Sets the amount for the builder.Sets the base currency for the builder after formatting it to follow the required symbol format.build()Builds and returns a new instance ofLatestRatesusing the current state of theLatestRates.Builder.Sets the date for the builder after validating it to ensure it is not earlier than January 4, 1994.Adds one or more currency symbols to the builder after formatting each symbol to follow the required format.symbols(Collection<String> symbols) Adds a collection of currency symbols to the builder after formatting each symbol to follow the required format.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
amount
Sets the amount for the builder.- Parameters:
amount- the amount value to be set, which can be a Double representing the desired amount- Returns:
- the current instance of the builder for method chaining
-
amount
Sets the amount for the builder.- Parameters:
amount- the amount value to be set, which can be a Double representing the desired amount- Returns:
- the current instance of the builder for method chaining
-
base
Sets the base currency for the builder after formatting it to follow the required symbol format.- Parameters:
base- the base currency symbol to be set, which must consist of exactly three alphabetical characters- Returns:
- the current instance of the builder for method chaining
- Throws:
IllegalArgumentException- if the provided base symbol is not exactly three alphabetical characters
-
build
Builds and returns a new instance ofLatestRatesusing the current state of theLatestRates.Builder.- Returns:
- a new
LatestRatesinstance configured with the base currency, date, and symbols set in the Builder
-
date
Sets the date for the builder after validating it to ensure it is not earlier than January 4, 1994.- Parameters:
date- theLocalDateto be set- Returns:
- the current instance of the builder for method chaining
- Throws:
IllegalArgumentException- if the provided date is earlier than January 4, 1994
-
symbols
Adds a collection of currency symbols to the builder after formatting each symbol to follow the required format.- Parameters:
symbols- the collection of currency symbols to be added, each of which must consist of exactly three alphabetical characters- Returns:
- the current instance of the builder for method chaining
- Throws:
IllegalArgumentException- if any of the symbols in the collection is not exactly three alphabetical characters
-
symbols
Adds one or more currency symbols to the builder after formatting each symbol to follow the required format.- Parameters:
symbols- one or more currency symbols to be added, each of which must consist of exactly three alphabetical characters- Returns:
- the current instance of the builder for method chaining
- Throws:
IllegalArgumentException- if any of the symbols provided is not exactly three alphabetical characters
-