Class RocketRestOptions


  • public class RocketRestOptions
    extends Object
    Configuration options for RocketRest API clients.

    This class provides a type-safe, centralized container for all configurable options across different client implementations. Options are stored as key-value pairs and can be retrieved with type-specific methods.

    Available Options

    Configuration options for RocketRest clients
    OptionTypeDefaultDescription
    RETRY_ENABLEDBooleantrueEnable automatic retry on failure
    MAX_RETRIESInteger3Maximum number of retry attempts
    RETRY_DELAYLong1000Delay between retries in milliseconds
    LOGGING_ENABLEDBooleantrueEnable request/response logging
    LOG_REQUEST_BODYBooleanfalseLog request body content
    LOG_RESPONSE_BODYBooleanfalseLog response body content
    ASYNC_POOL_SIZEInteger4Thread pool size for async operations

    Usage

    
     // Configure via RocketRestConfig builder
     RocketRestConfig config = RocketRestConfig.builder("https://api.example.com")
         .defaultOptions(options -> {
             options.set(RocketRestOptions.RETRY_ENABLED, true);
             options.set(RocketRestOptions.MAX_RETRIES, 5);
             options.set(RocketRestOptions.LOG_REQUEST_BODY, true);
         })
         .build();
    
     // Or configure directly on client
     RocketRest client = new RocketRest(config);
     client.configure(RocketRestOptions.RETRY_DELAY, 2000L);
     

    Reading Options

    
     RocketRestOptions options = new RocketRestOptions();
     boolean retryEnabled = options.getBoolean(RocketRestOptions.RETRY_ENABLED, false);
     int maxRetries = options.getInt(RocketRestOptions.MAX_RETRIES, 3);
     long delay = options.getLong(RocketRestOptions.RETRY_DELAY, 1000L);
     
    Since:
    1.0.0
    Author:
    guinetik <guinetik@gmail.com>
    See Also:
    RocketRestConfig, RocketRest.configure(String, Object)
    • Constructor Detail

      • RocketRestOptions

        public RocketRestOptions()
        Creates a new ClientOptions with default values.
    • Method Detail

      • set

        public RocketRestOptions set​(String key,
                                     Object value)
        Sets an option value.
        Parameters:
        key - The option key.
        value - The option value.
        Returns:
        This option instance for method chaining.
      • getKeys

        public Set<String> getKeys()
        Gets all option keys.
        Returns:
        Set of all option keys.
      • getRaw

        public Object getRaw​(String key)
        Gets the raw option value without type casting.
        Parameters:
        key - The option key.
        Returns:
        The raw option value, or null if not set.
      • get

        public <T> T get​(String key,
                         T defaultValue)
        Gets an option value.
        Type Parameters:
        T - The expected type of the option value.
        Parameters:
        key - The option key.
        defaultValue - The default value to return if the option is not set.
        Returns:
        The option value, or the default value if not set.
      • getBoolean

        public boolean getBoolean​(String key,
                                  boolean defaultValue)
        Gets a boolean option value.
        Parameters:
        key - The option key.
        defaultValue - The default value to return if the option is not set.
        Returns:
        The boolean option value.
      • getInt

        public int getInt​(String key,
                          int defaultValue)
        Gets an integer option value.
        Parameters:
        key - The option key.
        defaultValue - The default value to return if the option is not set.
        Returns:
        The integer option value.
      • getLong

        public long getLong​(String key,
                            long defaultValue)
        Gets a long option value.
        Parameters:
        key - The option key.
        defaultValue - The default value to return if the option is not set.
        Returns:
        The long option value.
      • contains

        public boolean contains​(String feature)