Package com.github.trelawnm.weathersdk
Class WeatherSDK.Builder
java.lang.Object
com.github.trelawnm.weathersdk.WeatherSDK.Builder
- Enclosing class:
- WeatherSDK
Builder for configuring WeatherSDK instances with fluent interface.
Ensures required parameters are provided and applies sensible defaults.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and validates a new WeatherSDK instance with the configured parametersSets the custom endpoint URL for API requestsSets the maximum size for stored datamode(WeatherSDKMode mode) Sets the operation mode for the SDKpollingInterval(Duration pollingInterval) Sets the polling interval for POLLING mode
-
Constructor Details
-
Builder
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
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
Sets the operation mode for the SDK- Parameters:
mode- the operation mode (default: ON_DEMAND)- Returns:
- the current Builder instance for method chaining
-
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
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
Builds and validates a new WeatherSDK instance with the configured parameters- Returns:
- a new configured WeatherSDK instance
- Throws:
IllegalStateException- if any validation checks fail
-