Class OptionsInfo


  • public final class OptionsInfo
    extends java.lang.Object
    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:
    for options details
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.Class<java.lang.Enum>> getOptionGroups()
      In contrast to getOptions() returns only enum types of used options.
      <T extends java.lang.Enum & Option>
      java.util.Set<T>
      getOptions()
      NOTE: as option could be accessed at any time by guice service, so more options could appear over time.
      <V> V getValue​(java.lang.Enum option)  
      boolean isSet​(java.lang.Enum option)
      All options are set in application (before application start) and will not change after.
      boolean isUsed​(java.lang.Enum option)
      Option usage tracked when option read by either bundle or from guice service.
      boolean knowsOption​(java.lang.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).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getOptions

        public <T extends java.lang.Enum & Option> java.util.Set<T> 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:
        for option groups
      • getOptionGroups

        public java.util.List<java.lang.Class<java.lang.Enum>> getOptionGroups()
        In contrast to getOptions() returns only enum types of used options. For example, GuiceyOptions is enum type for core guicey options.
        Returns:
        list of used option enums sorted by name
      • getValue

        public <V> V getValue​(java.lang.Enum option)
        Type Parameters:
        V - value type
        Parameters:
        option - option enum
        Returns:
        current option value (default or defined)
        Throws:
        java.lang.IllegalArgumentException - if option was not used
      • isUsed

        public boolean isUsed​(java.lang.Enum option)
        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:
        java.lang.IllegalArgumentException - if option was not used
      • isSet

        public boolean isSet​(java.lang.Enum option)
        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:
        java.lang.IllegalArgumentException - if option was not used
      • knowsOption

        public boolean knowsOption​(java.lang.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).
        Parameters:
        option - option enum
        Returns:
        true if option registered (was used or set), false otherwise