Record Class ExchangeRates
java.lang.Object
java.lang.Record
net.thauvin.erik.frankfurter.models.ExchangeRates
- Record Components:
amount- the amount of the base currencybase- the base currencydate- the date of the exchange ratesrates- the exchange rates
public record ExchangeRates(Double amount, String base, LocalDate date, Map<String,Double> rates)
extends Record
Represents the exchange rates for a base currency.
- 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.date()Returns the value of thedaterecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanhasRateFor(String symbol) Checks if the exchange rates contain the specified currency symbol.Retrieves the exchange rate for the specified currency symbol.rates()Returns the value of theratesrecord component.symbols()Retrieves the set of all currency symbols available in the exchange rates.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ExchangeRates
Constructs a new instance of the ExchangeRates record.- Parameters:
amount- the amount of the base currencybase- the base currencydate- the date of the exchange ratesrates- the exchange rates map, where keys are currency symbols and values are their respective rates
-
-
Method Details
-
hasRateFor
Checks if the exchange rates contain the specified currency symbol.- Parameters:
symbol- the currency symbol to check for- Returns:
trueif the exchange rates contain the symbol,falseotherwise
-
rateFor
Retrieves the exchange rate for the specified currency symbol.- Parameters:
symbol- the currency symbol
-
symbols
Retrieves the set of all currency symbols available in the exchange rates.- Returns:
- a set of strings representing the currency symbols
-
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
-
date
Returns the value of thedaterecord component.- Returns:
- the value of the
daterecord component
-
rates
Returns the value of theratesrecord component.- Returns:
- the value of the
ratesrecord component
-