Class RatesConfig

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

public final class RatesConfig extends Object
Immutable configuration for constructing Frankfurter /rates queries.

Use new RatesConfig.Builder() to create instances. All parameters are optional.

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

    • hashCode

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

      The hash code is computed from the parameters map. 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 RatesConfig instances are equal if they have the same parameters.

      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()
      Overrides:
      toString in class Object
    • applyTo

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

      Constructs a URI for the /rates endpoint with optional query parameters.

      Parameters:
      baseUri - the base API endpoint, e.g. https://api.frankfurter.app/
      Returns:
      a new URI with the query parameters appended
      Throws:
      NullPointerException - if baseUri is null
      IllegalArgumentException - if the URI cannot be built