Class Providers
java.lang.Object
net.thauvin.erik.frankfurter.models.Providers
- All Implemented Interfaces:
Iterable<Provider>,ProvidersResult
Represents the set of providers returned by the Frankfurter
/providers endpoint.
The API returns a JSON array of provider entries. This type normalizes the structure into a list and provides simple lookup helpers.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
- API Note:
- This class is immutable and thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionProviders(Collection<Provider> providers) Creates a new immutable container for the given list of providers. -
Method Summary
Modifier and TypeMethodDescriptionbooleanFinds a provider by its key.static ProvidersParses a JSON array of provider entries into aProvidersinstance.inthashCode()booleanisEmpty()Returnstrueif there are no providers in the list.iterator()list()Returns all provider entries.searchByName(String name) Searches providers by name substring.intsize()Returns the number of provider entries.toString()Returns a string representation showing size and preview some entries for debugging.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Providers
Creates a new immutable container for the given list of providers.- Parameters:
providers- the list of provider entries- Throws:
NullPointerException- ifprovidersisnullor contains null elements
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
toString
Returns a string representation showing size and preview some entries for debugging. -
iterator
-
fromJson
Parses a JSON array of provider entries into aProvidersinstance.- Parameters:
json- the JSON response- Returns:
- the parsed providers
- Throws:
NullPointerException- ifjsonisnullIllegalArgumentException- ifjsonis malformed or contains null elements
-
find
Finds a provider by its key.- Parameters:
key- the provider key- Returns:
- an optional containing the matching provider
- Throws:
NullPointerException- ifkeyisnull
-
isEmpty
public boolean isEmpty()Returnstrueif there are no providers in the list.- Returns:
trueif the list is empty,falseotherwise
-
list
Returns all provider entries.- Returns:
- the list of providers
-
searchByName
Searches providers by name substring.- Parameters:
name- the substring to match- Returns:
- the list of matching providers if any
- Throws:
NullPointerException- ifnameisnull
-
size
public int size()Returns the number of provider entries.- Returns:
- the number of entries
-