Class Providers
java.lang.Object
net.thauvin.erik.frankfurter.models.Providers
- All Implemented Interfaces:
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
-
Constructor Summary
ConstructorsConstructorDescriptionProviders(Collection<Provider> list) Creates a new immutable container for the given list of providers. -
Method Summary
Modifier and TypeMethodDescriptionFinds a provider by its key.static ProvidersParses a JSON array of provider entries into aProvidersinstance.booleanisEmpty()Returnstrueif there are no providers in the list.list()Returns all provider entries.searchByName(String name) Searches providers by name substring.intsize()Returns the number of provider entries.
-
Constructor Details
-
Providers
Creates a new immutable container for the given list of providers.- Parameters:
list- the list of provider entries
-
-
Method Details
-
fromJson
Parses a JSON array of provider entries into aProvidersinstance.- Parameters:
json- the JSON response- Returns:
- the parsed providers
-
find
Finds a provider by its key.- Parameters:
key- the provider key- Returns:
- an optional containing the matching provider
-
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
-
size
public int size()Returns the number of provider entries.- Returns:
- the number of entries
-