Class WeatherSDK.Builder

java.lang.Object
com.github.trelawnm.weathersdk.WeatherSDK.Builder
Enclosing class:
WeatherSDK

public static class WeatherSDK.Builder extends Object
Builder for configuring WeatherSDK instances with fluent interface. Ensures required parameters are provided and applies sensible defaults.
  • Constructor Details

    • Builder

      public Builder(String key)
      Constructs a new Builder with the required API key
      Parameters:
      key - the OpenWeatherMap API key (required)
      Throws:
      IllegalArgumentException - if the API key is null or blank
  • Method Details

    • endpoint

      public WeatherSDK.Builder endpoint(String endpoint)
      Sets the custom endpoint URL for API requests
      Parameters:
      endpoint - the endpoint URL (default: "https://api.openweathermap.org/data/2.5/weather")
      Returns:
      the current Builder instance for method chaining
    • mode

      public WeatherSDK.Builder mode(WeatherSDKMode mode)
      Sets the operation mode for the SDK
      Parameters:
      mode - the operation mode (default: ON_DEMAND)
      Returns:
      the current Builder instance for method chaining
    • pollingInterval

      public WeatherSDK.Builder pollingInterval(Duration pollingInterval)
      Sets the polling interval for POLLING mode
      Parameters:
      pollingInterval - the interval between polls (default: 10 minutes)
      Returns:
      the current Builder instance for method chaining
    • maxSize

      public WeatherSDK.Builder maxSize(Integer size)
      Sets the maximum size for stored data
      Parameters:
      size - the number of DTO instanse remember too (default: 10)
      Returns:
      the current Builder instance for method chaining
    • build

      public WeatherSDK build()
      Builds and validates a new WeatherSDK instance with the configured parameters
      Returns:
      a new configured WeatherSDK instance
      Throws:
      IllegalStateException - if any validation checks fail