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

public final class Filters extends Object
Common filters for configuration information filtering in ConfigurationInfo.getItems(ConfigItem, Predicate) and ConfigurationInfo.getItems(Predicate). Use Predicate.and(Predicate), Predicate.or(Predicate) and Predicate.negate() to reuse default filters.
Since:
06.07.2016
  • Method Details

    • enabled

      public static <T extends ItemInfo> Predicate<T> enabled()
      Filter for enabled items. Not all items support disable (DisableSupport). Items not supporting disable considered enabled (so it's safe to apply filter for all items).
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Returns:
      enabled items filter
    • disabled

      public static <T extends ItemInfo> Predicate<T> disabled()
      Filter for disabled items. Not all items support disable (DisableSupport). Items not supporting disable considered enabled (so it's safe to apply filter for all items).
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Returns:
      enabled items filter
    • disabledBy

      public static <T extends ItemInfo> Predicate<T> disabledBy(ItemId scope)
      Filter for items disabled in specified scope. Not all items support disable (DisableSupport). Items not supporting disable considered enabled (so it's safe to apply filter for all items).
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      scope - target scope
      Returns:
      items disabled in scope filter
    • disabledBy

      public static <T extends ItemInfo> Predicate<T> disabledBy(Class<?> type)
      Shortcut for disabledBy(ItemId).
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      type - target scope type
      Returns:
      items disabled in scope filter
    • fromScan

      public static <T extends ItemInfo> Predicate<T> fromScan()
      Filter for items registered with classpath scan. Not all items support classpath scan ScanSupport. Items not supporting scan are considered not resolved by scan (so it's safe to apply filter for all items).
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Returns:
      items from classpath scan filter
    • registrationScope

      public static <T extends ItemInfo> Predicate<T> registrationScope(ItemId scope)
      Filter for items registered by specified context. Context class could be Application, ClasspathScanner, GuiceyBundleLookup and classes implementing GuiceyBundle. Safe to apply filter for all items.

      Note: counts only actual registration, ignoring duplicate (rejected) registrations (see registeredBy(Class) for filter counting all registrations).

      Note: if scope key contain class only (without instance identity) and multiple scope instances were registered, then all object from all instance scopes will be returned.

      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      scope - scope class
      Returns:
      items registered in specified context filter
      See Also:
    • registrationScope

      public static <T extends ItemInfo> Predicate<T> registrationScope(ConfigScope specialScope)
      Shortcut for registrationScope(ItemId) for special scopes (like classpath scan, bundles lookup etc).
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      specialScope - special scope type
      Returns:
      items registered in specified context filter
    • registrationScope

      public static <T extends ItemInfo> Predicate<T> registrationScope(Class<?> type)
      Shortcut for registrationScope(ItemId).

      Note: if type is a bundle type and multiple bundle instances were registered, then all registered items from all bundle instances will be returned (will affect multiple scopes).

      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      type - scope type
      Returns:
      items registered in specified context filter
    • registeredBy

      public static <T extends ItemInfo> Predicate<T> registeredBy(ItemId scope)
      In contrast to registrationScope(ItemId) this filter returns item for all scopes mentioned item (including scopes where registration was considered duplicate).
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      scope - scope key
      Returns:
      items registered in specified context filter
      See Also:
    • registeredBy

      public static <T extends ItemInfo> Predicate<T> registeredBy(ConfigScope specialScope)
      Shortcut for registeredBy(ItemId) for special scopes (like classpath scan, bundles lookup etc).
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      specialScope - special scope type
      Returns:
      items registered in specified context filter
    • registeredBy

      public static <T extends ItemInfo> Predicate<T> registeredBy(Class<?> type)
      Shortcut for registeredBy(ItemId) for scope classes.
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      type - scope class
      Returns:
      items registered in specified context filter
    • type

      public static <T extends ItemInfo> Predicate<T> type(ConfigItem... types)
      Filter used for multi-type searches to filter out item types. In order to filter out only one type, may be used in conjunction with Predicate.negate().
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      types - item types to match
      Returns:
      items of type filter
    • type

      public static <T extends ItemInfo> Predicate<T> type(Class<?> type)
      Filter used for instance items (bundle, module) selection by type.
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Parameters:
      type - item class
      Returns:
      items of class filter
    • lookupBundles

      public static Predicate<GuiceyBundleItemInfo> lookupBundles()
      Filter for bundles resolved by lookup mechanism. Use only for ConfigItem.Bundle items.
      Returns:
      bundles resolved by lookup filter
    • transitiveBundles

      public static Predicate<BundleItemInfo> transitiveBundles()
      Filter for transitive bundles: bundles registered only by other bundles (and never directly). Applied to both guicey and dropwizard bundles.
      Returns:
      transitive bundled filter
    • bundles

      public static <T extends BundleItemInfo> Predicate<T> bundles()
      Guicey and dropwizard bundles are pretty much unified and likely to be queried together for reporting.
      Type Parameters:
      T - expected info container type (if used within single configuration type)
      Returns:
      bundle predicate (guicey or dropwizard)
    • guiceyBundles

      public static Predicate<GuiceyBundleItemInfo> guiceyBundles()
      Returns:
      guicey bundles predicate
    • dropwizardBundles

      public static Predicate<GuiceyBundleItemInfo> dropwizardBundles()
      Returns:
      dropwizard bundles predicate
    • extensions

      public static Predicate<ExtensionItemInfo> extensions()
      Returns:
      extensions predicate
    • installedBy

      public static Predicate<ExtensionItemInfo> installedBy(Class<? extends FeatureInstaller> type)
      Filter for extensions installed by specified installer. Use only for ConfigItem.Extension items.
      Parameters:
      type - installer class
      Returns:
      extensions installed by specified installer filter
    • fromBinding

      public static Predicate<ExtensionItemInfo> fromBinding()
      Filter for extensions detected from guice bindings. Use only for ConfigItem.Extension items.
      Returns:
      extensions resolved from binding filter
    • webExtension

      public static Predicate<ExtensionItemInfo> webExtension()
      Filter for web extensions (everything web-related, including jersey extensions). Use only for ConfigItem.Extension items.
      Returns:
      web extensions matcher
    • jerseyExtension

      public static Predicate<ExtensionItemInfo> jerseyExtension()
      Filter for jersey extensions. Use only for ConfigItem.Extension items.
      Returns:
      jersey extensions matcher
    • modules

      public static Predicate<ModuleItemInfo> modules()
      Returns:
      guice modules predicate
    • overridingModule

      public static Predicate<ModuleItemInfo> overridingModule()
      Filter for overriding modules. Use only for ConfigItem.Module items.
      Returns:
      overriding modules filter
    • installers

      public static Predicate<InstallerItemInfo> installers()
      Returns:
      installers predicate