Record Class SeriesRates

java.lang.Object
java.lang.Record
net.thauvin.erik.frankfurter.models.SeriesRates
Record Components:
amount - the amount to be converted or used in calculations
base - the base currency for the time series of exchange rates
startDate - the start date of the time series, formatted as a string
endDate - the end date of the time series, formatted as a string
rates - a map where the keys are dates (LocalDate) and the values are maps of currency codes to their respective exchange rates as doubles

public record SeriesRates(Double amount, String base, String startDate, String endDate, Map<LocalDate,Map<String,Double>> rates) extends Record
Represents exchange rates over a series of dates for multiple currencies.
Since:
0.9.0
Author:
Erik C. Thauvin
  • Constructor Details

    • SeriesRates

      public SeriesRates(Double amount, String base, String startDate, String endDate, Map<LocalDate,Map<String,Double>> rates)
      Constructs an instance of SeriesRates using the provided exchange rate time series.
      Parameters:
      amount - the amount to be converted or used in calculations
      base - the base currency for the time series of exchange rates
      startDate - the start date of the time series, formatted as a string
      endDate - the end date of the time series, formatted as a string
      rates - a map where the keys are dates (LocalDate) and the values are maps of currency codes to their respective exchange rates as doubles
  • Method Details

    • dates

      public Set<LocalDate> dates()
      Retrieves the set of dates for which exchange rates are available in the time series.
      Returns:
      the set of dates
    • endLocalDate

      public LocalDate endLocalDate()
      Retrieves the end date of the time series.
      Returns:
      the end date as a LocalDate
    • hasRatesFor

      public boolean hasRatesFor(LocalDate date)
      Checks if exchange rates are available for the specified date.
      Parameters:
      date - the date for which to check the availability of exchange rates
      Returns:
      true if exchange rates are available for the specified date, false otherwise
    • hasSymbolFor

      public boolean hasSymbolFor(LocalDate date, String symbol)
      Checks if a symbol is available for a specified date in the exchange rate time series.
      Parameters:
      date - the LocalDate for which to check the availability of the symbol
      symbol - the currency symbol to check for availability
      Returns:
      true if the symbol is available for the specified date, false otherwise
    • rateFor

      public Double rateFor(LocalDate date, String currencySymbol)
      Retrieves the exchange rate for a specific date and currency symbol from the time series.
      Parameters:
      date - the date for which the exchange rate is to be retrieved, formatted as a string
      currencySymbol - the currency symbol for which the exchange rate is to be retrieved
      Returns:
      The exchange rate for the specified date and currency symbol, or null if no rate is available
    • ratesFor

      public Map<String,Double> ratesFor(LocalDate date)
      Retrieves the exchange rates for all currencies on the specified date.
      Parameters:
      date - the date for which the exchange rates are to be retrieved as a LocalDate
      Returns:
      a map of currency symbols to their respective exchange rates on the specified date, or null if no rates are available for the date
    • startLocalDate

      public LocalDate startLocalDate()
      Retrieves the start date of the time series.
      Returns:
      the start date as a LocalDate
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • amount

      public Double amount()
      Returns the value of the amount record component.
      Returns:
      the value of the amount record component
    • base

      public String base()
      Returns the value of the base record component.
      Returns:
      the value of the base record component
    • startDate

      public String startDate()
      Returns the value of the startDate record component.
      Returns:
      the value of the startDate record component
    • endDate

      public String endDate()
      Returns the value of the endDate record component.
      Returns:
      the value of the endDate record component
    • rates

      public Map<LocalDate,Map<String,Double>> rates()
      Returns the value of the rates record component.
      Returns:
      the value of the rates record component