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 calculationsbase- the base currency for the time series of exchange ratesstartDate- the start date of the time series, formatted as a stringendDate- the end date of the time series, formatted as a stringrates- 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionamount()Returns the value of theamountrecord component.base()Returns the value of thebaserecord component.dates()Retrieves the set of dates for which exchange rates are available in the time series.endDate()Returns the value of theendDaterecord component.Retrieves the end date of the time series.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanhasRatesFor(LocalDate date) Checks if exchange rates are available for the specified date.booleanhasSymbolFor(LocalDate date, String symbol) Checks if a symbol is available for a specified date in the exchange rate time series.Retrieves the exchange rate for a specific date and currency symbol from the time series.rates()Returns the value of theratesrecord component.Retrieves the exchange rates for all currencies on the specified date.Returns the value of thestartDaterecord component.Retrieves the start date of the time series.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SeriesRates
public SeriesRates(Double amount, String base, String startDate, String endDate, Map<LocalDate, Map<String, Double>> rates) Constructs an instance ofSeriesRatesusing the provided exchange rate time series.- Parameters:
amount- the amount to be converted or used in calculationsbase- the base currency for the time series of exchange ratesstartDate- the start date of the time series, formatted as a stringendDate- the end date of the time series, formatted as a stringrates- 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
Retrieves the set of dates for which exchange rates are available in the time series.- Returns:
- the set of dates
-
endLocalDate
Retrieves the end date of the time series.- Returns:
- the end date as a
LocalDate
-
hasRatesFor
Checks if exchange rates are available for the specified date.- Parameters:
date- the date for which to check the availability of exchange rates- Returns:
trueif exchange rates are available for the specified date,falseotherwise
-
hasSymbolFor
Checks if a symbol is available for a specified date in the exchange rate time series.- Parameters:
date- theLocalDatefor which to check the availability of the symbolsymbol- the currency symbol to check for availability- Returns:
trueif the symbol is available for the specified date,falseotherwise
-
rateFor
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 stringcurrencySymbol- 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
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 aLocalDate- 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
Retrieves the start date of the time series.- Returns:
- the start date as a
LocalDate
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
amount
Returns the value of theamountrecord component.- Returns:
- the value of the
amountrecord component
-
base
Returns the value of thebaserecord component.- Returns:
- the value of the
baserecord component
-
startDate
Returns the value of thestartDaterecord component.- Returns:
- the value of the
startDaterecord component
-
endDate
Returns the value of theendDaterecord component.- Returns:
- the value of the
endDaterecord component
-
rates
Returns the value of theratesrecord component.- Returns:
- the value of the
ratesrecord component
-