Class Frankfurter

java.lang.Object
net.thauvin.erik.frankfurter.Frankfurter

@NullMarked public final class Frankfurter extends Object
Client for the Frankfurter.dev exchange rates API.

Provides methods to fetch currency metadata, providers, and exchange rates. All calls are blocking. Instances are thread-safe and reusable.

Timeouts: 5s connect timeout, 10s request timeout by default. Both must be positive.

See Also:
  • Constructor Details

    • Frankfurter

      public Frankfurter()
      Creates a new client using the default API endpoint, default HttpClient with default timeouts.
    • Frankfurter

      public Frankfurter(Duration requestTimeout)
      Creates a new client using the default API endpoint and connect timeout, with a custom request timeout.
      Parameters:
      requestTimeout - the request timeout (must be positive, not null)
      Throws:
      IllegalArgumentException - if requestTimeout is zero or negative
    • Frankfurter

      public Frankfurter(Duration connectTimeout, Duration requestTimeout)
      Creates a new client using the default API endpoint with custom connect and request timeouts.
      Parameters:
      connectTimeout - the connect timeout (must be positive, not null)
      requestTimeout - the request timeout (must be positive, not null)
      Throws:
      IllegalArgumentException - if either timeout is zero or negative
    • Frankfurter

      public Frankfurter(URI baseUri)
      Creates a new client using the given base URI, default HttpClient with default timeouts.
      Parameters:
      baseUri - the base API URI (must not be null)
    • Frankfurter

      public Frankfurter(HttpClient client, URI baseUri)
      Creates a new client using the given HTTP client and base URI with default 10s request timeout.

      Note: The connect timeout is determined by the provided HttpClient. If the client was built without an explicit connect timeout, getConnectTimeout() will return an empty Optional.

      Parameters:
      client - the HTTP client to use (must not be null)
      baseUri - the base API URI (must not be null)
    • Frankfurter

      public Frankfurter(HttpClient client, URI baseUri, Duration requestTimeout)
      Creates a new client using the given HTTP client, base URI, and request timeout.

      Note: The connect timeout is determined by the provided HttpClient. If the client was built without an explicit connect timeout, getConnectTimeout() will return an empty Optional.

      Parameters:
      client - the HTTP client to use (must not be null)
      baseUri - the base API URI (must not be null)
      requestTimeout - the request timeout (must be positive, not null)
      Throws:
      IllegalArgumentException - if requestTimeout is zero or negative
  • Method Details