Class ConfigurationInfo

java.lang.Object
ru.vyarus.dropwizard.guice.module.context.ConfigurationInfo

public final class ConfigurationInfo extends Object
Public api for collected guicey configuration info. In contrast to ConfigurationContext, used during configuration, contains only configuration item ids (item ids used instead of pure classes because multiple instances of the same type could be registered (e.g. multiple bundles or modules)).

Configuration info may be used for any kind of diagnostics: configuration logging, configuration tree rendering, automatic configuration warnings generation etc.

Configuration items are stored in registration order. Information querying is implemented with help of java 8 Predicate.

Available for direct injection, but prefer accessing from GuiceyConfigurationInfo.getData().

Since:
06.07.2016
See Also:
  • Constructor Details

    • ConfigurationInfo

      public ConfigurationInfo(ConfigurationContext context)
      Create configuration info.
      Parameters:
      context - configuration context
  • Method Details

    • getItems

      public <T> List<ItemId<T>> getItems(ConfigItem type)
      Pay attention that disabled (or disabled and never registered) items are also returned.
      Type Parameters:
      T - expected class
      Parameters:
      type - configuration item type
      Returns:
      registered item ids of required type in registration order or empty list if nothing registered
    • getItems

      public <T, K extends ItemInfo> List<ItemId<T>> getItems(ConfigItem type, Predicate<K> filter)
      Used to query items of one configuration type (e.g. only installers or bundles). Some common filters are predefined in Filters. Use Predicate.and(Predicate), Predicate.or(Predicate) and Predicate.negate() to reuse default filters.

      Pay attention that disabled (or disabled and never registered) items are also returned.

      Type Parameters:
      T - expected class
      K - expected info container class
      Parameters:
      type - configuration item type
      filter - predicate to filter definitions
      Returns:
      registered item ids in registration order, filtered with provided filter or empty list
    • getItems

      public List<ItemId<Object>> getItems(Predicate<? extends ItemInfo> filter)
      Used to query items of all configuration types. May be useful to build configuration tree (e.g. to search all items configured by bundle or by classpath scan). Some common filters are predefined in Filters. Use Predicate.and(Predicate), Predicate.or(Predicate) and Predicate.negate() to reuse default filters.

      Pay attention that disabled (or disabled and never registered) items are also returned.

      Parameters:
      filter - predicate to filter definitions
      Returns:
      registered item ids in registration order, filtered with provided filter or empty list
    • getItems

      public List<ItemId<Object>> getItems(Class<?> type)
      Parameters:
      type - item type
      Returns:
      registered items by type (possibly multiple results for instance item)
    • getInfo

      public <T extends ItemInfo> T getInfo(ItemId id)
      NOTE: it will not return first instance of type if called as getInfo(ItemId.from(Bundle.class)))! It could only return non null object for instance type if exact instance identity provided or disable - only info (when item was disabled but never registered then calling with id ItemId.from(Bundle.class) will return disable item info (information that all instances of class are disabled)). But note, that general disable into is not created if at least one instance was registered.
      Type Parameters:
      T - expected configuration container type
      Parameters:
      id - configured item id
      Returns:
      item configuration info or null if item not registered
      See Also:
    • getInfos

      public <T extends ItemInfo> List<T> getInfos(Class<?> type)
      Returns all registrations of type. For class based extensions will return list of one element (the same result as getInfo(ItemId.from(type))).For instance types will return all registered instances of type.
      Type Parameters:
      T - item info type
      Parameters:
      type - item class
      Returns:
      all registrations of type or empty list if nothing registered
    • getInfos

      public <T extends ItemInfo> List<T> getInfos(ConfigItem type, Predicate<T> filter)
      The simple way to receive a large set of info objects, instead of just ids. Useful for sorting.
      Type Parameters:
      T - item type
      Parameters:
      type - required item type
      filter - filter
      Returns:
      all registrations matching filter or empty list if nothing registered
    • getHooks

      public List<Class<? extends GuiceyConfigurationHook>> getHooks()
      Returns:
      types of executed hooks