Record Class ExchangeRates

java.lang.Object
java.lang.Record
net.thauvin.erik.frankfurter.models.ExchangeRates
Record Components:
amount - the amount of the base currency
base - the base currency
date - the date of the exchange rates
rates - 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 Details

    • ExchangeRates

      public ExchangeRates(Double amount, String base, LocalDate date, Map<String,Double> rates)
      Constructs a new instance of the ExchangeRates record.
      Parameters:
      amount - the amount of the base currency
      base - the base currency
      date - the date of the exchange rates
      rates - the exchange rates map, where keys are currency symbols and values are their respective rates
  • Method Details

    • hasRateFor

      public boolean hasRateFor(String symbol)
      Checks if the exchange rates contain the specified currency symbol.
      Parameters:
      symbol - the currency symbol to check for
      Returns:
      true if the exchange rates contain the symbol, false otherwise
    • rateFor

      public Double rateFor(String symbol)
      Retrieves the exchange rate for the specified currency symbol.
      Parameters:
      symbol - the currency symbol
    • symbols

      public Set<String> symbols()
      Retrieves the set of all currency symbols available in the exchange rates.
      Returns:
      a set of strings representing the currency symbols
    • 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
    • date

      public LocalDate date()
      Returns the value of the date record component.
      Returns:
      the value of the date record component
    • rates

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