Class OptionsInfo
java.lang.Object
ru.vyarus.dropwizard.guice.module.context.option.OptionsInfo
Provides access to used options and values. Contains only options either set
(in
GuiceBundle) or read (by guicey, bundles or guice services).
Instance bound to guice context and available for injection. Also may be accessed through
GuiceyConfigurationInfo.getOptions().
NOTE: service just provides info of already used options (consultation only service - for reporting).
If option wasn't used then default value will not be returned (error will be thrown). Option value read will not
mark option as used. Do not use it for reading option value (for actual option usage): use Options instead.
Most methods accept simple Enum instead of Enum & Option to simplify generic usage: if not allowed enum
value will be used methods will throw exceptions. knowsOption(Enum) method may be used to
safely check enum value before calling actual data methods.
- Since:
- 11.08.2016
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIn contrast togetOptions()returns only enum types of used options.NOTE: as option could be accessed at any time by guice service, so more options could appear over time.<V> VbooleanAll options are set in application (before application start) and will not change after.booleanOption usage tracked when option read by either bundle or from guice service.booleanknowsOption(Enum option) Use this method to check if option is available for reporting (option details methods will fail with exception if not known option will be provided).
-
Constructor Details
-
OptionsInfo
Create info.- Parameters:
support- options support
-
-
Method Details
-
getOptions
NOTE: as option could be accessed at any time by guice service, so more options could appear over time. As a consequence, it can't be known for sure that option is not used, for example, just after application start.- Type Parameters:
T- helper type to define option- Returns:
- set of all used options (either read or set)
- See Also:
-
getOptionGroups
In contrast togetOptions()returns only enum types of used options. For example,GuiceyOptionsis enum type for core guicey options.- Returns:
- list of used option enums sorted by name
-
getValue
- Type Parameters:
V- value type- Parameters:
option- option enum- Returns:
- current option value (default or defined)
- Throws:
IllegalArgumentException- if option was not used
-
isUsed
Option usage tracked when option read by either bundle or from guice service. Option may be read in any time of application life so used value may change over time (even new options could appear for reporting).- Parameters:
option- option enum- Returns:
- true if option was read, false if option set but never used
- Throws:
IllegalArgumentException- if option was not used
-
isSet
All options are set in application (before application start) and will not change after.- Parameters:
option- option enum- Returns:
- true if option was manually defined, false when default value used
- Throws:
IllegalArgumentException- if option was not used
-
knowsOption
Use this method to check if option is available for reporting (option details methods will fail with exception if not known option will be provided).- Parameters:
option- option enum- Returns:
- true if option registered (was used or set), false otherwise
-