Class LatestRates.Builder

java.lang.Object
net.thauvin.erik.frankfurter.LatestRates.Builder
Enclosing class:
LatestRates

public static class LatestRates.Builder extends Object
Builder class to create and configure an instance of LatestRates.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • amount

      public LatestRates.Builder amount(Double 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

      public LatestRates.Builder amount(int 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

      public LatestRates.Builder base(String 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

      public LatestRates build()
      Builds and returns a new instance of LatestRates using the current state of the LatestRates.Builder.
      Returns:
      a new LatestRates instance configured with the base currency, date, and symbols set in the Builder
    • date

      public LatestRates.Builder date(LocalDate date)
      Sets the date for the builder after validating it to ensure it is not earlier than January 4, 1994.
      Parameters:
      date - the LocalDate to 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

      public LatestRates.Builder symbols(Collection<String> 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

      public LatestRates.Builder symbols(String... 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