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.
-
Constructor Summary
ConstructorsConstructorDescriptionCurrencies(Collection<Currency> currencies) Creates a new immutable container for the given list of currencies. -
Method Summary
Modifier and TypeMethodDescriptioncodes()Returns all ISO codes in this set.booleanCompares the specified object with this container for equality.Finds a currency by its ISO code.find(CurrencyCode code) Finds a currency by itsCurrencyCode.static CurrenciesParses a JSON array of currency entries into aCurrenciesinstance.inthashCode()Returns a hash code value for this object.booleanisEmpty()Returnstrueif the list is empty.Returns all distinct quote currencies asCurrencyCode, filtering out unknown codes.list()Returns all currency entries.searchByName(String name) Searches currencies by name substring.intsize()Returns the number of currencies.toString()Returns a string representation of this container.
-
Constructor Details
-
Currencies
Creates a new immutable container for the given list of currencies.- Parameters:
currencies- the list of currency entries- Throws:
NullPointerException- if currencies isnullor contains null elements
-
-
Method Details
-
hashCode
public int hashCode()Returns a hash code value for this object. -
equals
Compares the specified object with this container for equality. -
toString
Returns a string representation of this container. -
fromJson
Parses a JSON array of currency entries into aCurrenciesinstance.- Parameters:
json- the JSON response- Returns:
- the parsed currencies
- Throws:
NullPointerException- ifjsonisnullIllegalArgumentException- ifjsonis malformed or contains null elements
-
codes
Returns all ISO codes in this set.- Returns:
- an unmodifiable list of distinct ISO 4217 codes
-
find
Finds a currency by itsCurrencyCode.- Parameters:
code- the currency code- Returns:
- an optional containing the matching currency
- Throws:
NullPointerException- if code isnull- API Note:
- Use
find(String)for codes not inCurrencyCode
-
find
Finds a currency by its ISO code.- Parameters:
iso- the ISO 4217 currency code- Returns:
- an optional containing the matching currency
- Throws:
NullPointerException- if iso isnull
-
isEmpty
public boolean isEmpty()Returnstrueif the list is empty.- Returns:
trueif this container contains no currencies;falseotherwise
-
knownCodes
Returns all distinct quote currencies asCurrencyCode, filtering out unknown codes.- Returns:
- an unmodifiable list of known currency codes
-
list
Returns all currency entries.- Returns:
- an unmodifiable list of currencies
-
searchByName
Searches currencies by name substring.- Parameters:
name- the substring to match- Returns:
- the list of matching currencies if any
- Throws:
NullPointerException- if name isnull
-
size
public int size()Returns the number of currencies.- Returns:
- the total count of currency elements in this container
-