Class Currencies
java.lang.Object
net.thauvin.erik.frankfurter.models.Currencies
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionCurrencies(Collection<Currency> list) Creates a new immutable container for the given list of currencies. -
Method Summary
Modifier and TypeMethodDescriptionFinds a currency by its ISO code.static CurrenciesParses a JSON array of currency entries into aCurrenciesinstance.booleanisEmpty()Returnstrueif the list is empty.list()Returns all currency entries.searchByName(String name) Searches currencies by name substring.intsize()Returns the number of currencies.
-
Constructor Details
-
Currencies
Creates a new immutable container for the given list of currencies.- Parameters:
list- the list of currency entries
-
-
Method Details
-
fromJson
Parses a JSON array of currency entries into aCurrenciesinstance.- Parameters:
json- the JSON response- Returns:
- the parsed currencies
-
find
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()Returnstrueif the list is empty.- Returns:
trueif the list is empty
-
list
Returns all currency entries.- Returns:
- the list of currencies
-
searchByName
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
-