Record Class Provider

java.lang.Object
java.lang.Record
net.thauvin.erik.frankfurter.models.Provider

public record Provider(String key, String name, String description, String dataUrl, String termsUrl, LocalDate startDate, LocalDate endDate, List<String> currencies) extends Record
Represents a provider entry returned by the Frankfurter /providers endpoint.

The API supplies metadata for each provider, including its identifier, descriptive information, data source URLs, the date range of available data, and the list of currencies supported by the provider.

Only key and name are guaranteed to be non‑null. All other fields may be null depending on the provider and the data available from the API.

The currencies list is normalized to a non‑null, unmodifiable list to ensure safe iteration and predictable behavior.

Since:
1.0
Author:
Erik C. Thauvin
  • Constructor Details

    • Provider

      public Provider(@NonNull String key, @NonNull String name, @Nullable String description, @Nullable String dataUrl, @Nullable String termsUrl, @Nullable LocalDate startDate, @Nullable LocalDate endDate, @NonNull List<String> currencies)
      Validates required fields and normalizes optional values.

      This compact constructor enforces the non‑blank contract for key and name, which are the only required fields in a provider entry. All other fields may be null as supplied by the API.

      The currencies list is defensively normalized to a non‑null, unmodifiable list. When the API omits the field or supplies null, it is replaced with an empty list.

      Parameters:
      key - the provider identifier (must not be blank)
      name - the provider name (must not be blank)
      description - the provider description, or null
      dataUrl - the data source URL, or null
      termsUrl - the terms‑of‑use URL, or null
      startDate - the first date for which data is available, or null
      endDate - the last date for which data is available, or null
      currencies - the list of supported currencies, or null
      Throws:
      IllegalArgumentException - if key or name are blank
      NullPointerException - if key or name are null
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      @SerializedName("key") @NonNull public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • name

      @SerializedName("name") @NonNull public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • description

      @SerializedName("description") @Nullable public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • dataUrl

      @SerializedName("data_url") @Nullable public String dataUrl()
      Returns the value of the dataUrl record component.
      Returns:
      the value of the dataUrl record component
    • termsUrl

      @SerializedName("terms_url") @Nullable public String termsUrl()
      Returns the value of the termsUrl record component.
      Returns:
      the value of the termsUrl record component
    • startDate

      @SerializedName("start_date") @Nullable public LocalDate startDate()
      Returns the value of the startDate record component.
      Returns:
      the value of the startDate record component
    • endDate

      @SerializedName("end_date") @Nullable public LocalDate endDate()
      Returns the value of the endDate record component.
      Returns:
      the value of the endDate record component
    • currencies

      @SerializedName("currencies") @NonNull public List<String> currencies()
      Returns the value of the currencies record component.
      Returns:
      the value of the currencies record component