Class Currencies

java.lang.Object
net.thauvin.erik.frankfurter.models.Currencies
All Implemented Interfaces:
CurrenciesResult

@NullMarked public final class Currencies extends Object implements CurrenciesResult
Represents the set of currencies returned by the Frankfurter API.

The API returns a JSON array of currency entries. This type normalizes the structure into a list and provides simple lookup helpers.

Since:
1.0
Author:
Erik C. Thauvin
  • Constructor Details

    • Currencies

      public Currencies(Collection<Currency> list)
      Creates a new immutable container for the given list of currencies.
      Parameters:
      list - the list of currency entries
  • Method Details

    • fromJson

      public static Currencies fromJson(String json)
      Parses a JSON array of currency entries into a Currencies instance.
      Parameters:
      json - the JSON response
      Returns:
      the parsed currencies
    • find

      public Optional<Currency> find(String iso)
      Finds a currency by its ISO code.
      Parameters:
      iso - the ISO 4217 currency code
      Returns:
      an optional containing the matching currency
    • isEmpty

      public boolean isEmpty()
      Returns true if the list is empty.
      Returns:
      true if the list is empty
    • list

      public List<Currency> list()
      Returns all currency entries.
      Returns:
      the list of currencies
    • searchByName

      public List<Currency> searchByName(String name)
      Searches currencies by name substring.
      Parameters:
      name - the substring to match
      Returns:
      the list of matching currencies
    • size

      public int size()
      Returns the number of currencies.
      Returns:
      the number of currencies