Class RateConfig

java.lang.Object
net.thauvin.erik.frankfurter.config.RateConfig

public final class RateConfig extends Object
Immutable configuration for constructing Frankfurter /rate queries.

Use new RateConfig.Builder() to create instances. Only the quote currency is required. If base is omitted, the API defaults to EUR.

Since:
1.0
Author:
Erik C. Thauvin
API Note:
This class is thread-safe. All state is immutable.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Builder for RateConfig.
  • Method Summary

    Modifier and Type
    Method
    Description
    applyTo(URI baseUri)
    Applies this configuration to the given base URI.
    boolean
    Compares this configuration to the specified object for equality.
    int
    Returns a hash code value for this configuration.
    Returns a string representation of this configuration.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • hashCode

      public int hashCode()
      Returns a hash code value for this configuration.

      The hash code is computed from the base currency, quote currency, date, and providers. It is consistent with equals(Object): equal objects have equal hash codes.

      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object
    • equals

      public boolean equals(Object o)
      Compares this configuration to the specified object for equality.

      Two RateConfig instances are equal if they have the same base currency, quote currency, date, and providers. The comparison is order-sensitive for providers and case-sensitive for currency codes.

      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with
      Returns:
      true if the objects are equal, false otherwise
    • toString

      public String toString()
      Returns a string representation of this configuration.
      Overrides:
      toString in class Object
      Returns:
      a string describing the configuration parameters
    • applyTo

      @NonNull public URI applyTo(@NonNull URI baseUri)
      Applies this configuration to the given base URI.

      Constructs a URI for the /rate/{base}/{quote} endpoint with optional query parameters for date and providers.

      Parameters:
      baseUri - the base URI, e.g. https://api.frankfurter.app/
      Returns:
      the fully constructed URI for the rate query
      Throws:
      NullPointerException - if baseUri is null
      IllegalArgumentException - if the resulting URI is invalid