Class Providers

java.lang.Object
net.thauvin.erik.frankfurter.models.Providers
All Implemented Interfaces:
Iterable<Provider>, ProvidersResult

public final class Providers extends Object implements ProvidersResult, Iterable<Provider>
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 Details

    • Providers

      public Providers(@NonNull Collection<Provider> providers)
      Creates a new immutable container for the given list of providers.
      Parameters:
      providers - the list of provider entries
      Throws:
      NullPointerException - if providers is null or contains null elements
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Returns a string representation showing size and preview some entries for debugging.
      Overrides:
      toString in class Object
      Returns:
      a string with class name, size, and preview of entries
    • iterator

      @NonNull public Iterator<Provider> iterator()
      Specified by:
      iterator in interface Iterable<Provider>
    • fromJson

      @NonNull public static Providers fromJson(@NonNull String json)
      Parses a JSON array of provider entries into a Providers instance.
      Parameters:
      json - the JSON response
      Returns:
      the parsed providers
      Throws:
      NullPointerException - if json is null
      IllegalArgumentException - if json is malformed or contains null elements
    • find

      public Optional<Provider> find(@NonNull String key)
      Finds a provider by its key.
      Parameters:
      key - the provider key
      Returns:
      an optional containing the matching provider
      Throws:
      NullPointerException - if key is null
    • isEmpty

      public boolean isEmpty()
      Returns true if there are no providers in the list.
      Returns:
      true if the list is empty, false otherwise
    • list

      @NonNull public List<Provider> list()
      Returns all provider entries.
      Returns:
      the list of providers
    • searchByName

      @NonNull public List<Provider> searchByName(@NonNull String name)
      Searches providers by name substring.
      Parameters:
      name - the substring to match
      Returns:
      the list of matching providers if any
      Throws:
      NullPointerException - if name is null
    • size

      public int size()
      Returns the number of provider entries.
      Returns:
      the number of entries