Package com.guinetik.rr
Class RocketRestOptions
- java.lang.Object
-
- com.guinetik.rr.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 Option Type Default Description RETRY_ENABLEDBoolean true Enable automatic retry on failure MAX_RETRIESInteger 3 Maximum number of retry attempts RETRY_DELAYLong 1000 Delay between retries in milliseconds LOGGING_ENABLEDBoolean true Enable request/response logging LOG_REQUEST_BODYBoolean false Log request body content LOG_RESPONSE_BODYBoolean false Log response body content ASYNC_POOL_SIZEInteger 4 Thread 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)
-
-
Field Summary
Fields Modifier and Type Field Description static StringASYNC_POOL_SIZEstatic StringLOG_RAW_RESPONSEstatic StringLOG_REQUEST_BODYstatic StringLOG_RESPONSE_BODYstatic StringLOGGING_ENABLEDstatic StringMAX_LOGGED_BODY_LENGTHstatic StringMAX_RETRIESstatic StringRETRY_DELAYstatic StringRETRY_ENABLEDstatic StringTIMING_ENABLEDstatic StringTOKEN_URL
-
Constructor Summary
Constructors Constructor Description RocketRestOptions()Creates a new ClientOptions with default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(String feature)<T> Tget(String key, T defaultValue)Gets an option value.booleangetBoolean(String key, boolean defaultValue)Gets a boolean option value.intgetInt(String key, int defaultValue)Gets an integer option value.Set<String>getKeys()Gets all option keys.longgetLong(String key, long defaultValue)Gets a long option value.ObjectgetRaw(String key)Gets the raw option value without type casting.StringgetString(String feature, String defaultValue)RocketRestOptionsset(String key, Object value)Sets an option value.
-
-
-
Field Detail
-
RETRY_ENABLED
public static final String RETRY_ENABLED
- See Also:
- Constant Field Values
-
MAX_RETRIES
public static final String MAX_RETRIES
- See Also:
- Constant Field Values
-
RETRY_DELAY
public static final String RETRY_DELAY
- See Also:
- Constant Field Values
-
LOGGING_ENABLED
public static final String LOGGING_ENABLED
- See Also:
- Constant Field Values
-
TIMING_ENABLED
public static final String TIMING_ENABLED
- See Also:
- Constant Field Values
-
LOG_REQUEST_BODY
public static final String LOG_REQUEST_BODY
- See Also:
- Constant Field Values
-
LOG_RESPONSE_BODY
public static final String LOG_RESPONSE_BODY
- See Also:
- Constant Field Values
-
LOG_RAW_RESPONSE
public static final String LOG_RAW_RESPONSE
- See Also:
- Constant Field Values
-
MAX_LOGGED_BODY_LENGTH
public static final String MAX_LOGGED_BODY_LENGTH
- See Also:
- Constant Field Values
-
ASYNC_POOL_SIZE
public static final String ASYNC_POOL_SIZE
- See Also:
- Constant Field Values
-
TOKEN_URL
public static final String TOKEN_URL
- See Also:
- Constant Field 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.
-
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)
-
-