Class Filters
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.context.Filters
-
public final class Filters extends java.lang.Object
Common filters for configuration information filtering inConfigurationInfo.getItems(ConfigItem, Predicate)
andConfigurationInfo.getItems(Predicate)
. UsePredicate.and(Predicate)
,Predicate.or(Predicate)
andPredicate.negate()
to reuse default filters.- Since:
- 06.07.2016
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends BundleItemInfo>
java.util.function.Predicate<T>bundles()
Guicey and dropwizard bundles are pretty much unified and likely to be queried together for reporting.static <T extends ItemInfo>
java.util.function.Predicate<T>disabledBy(java.lang.Class<?> type)
Shortcut fordisabledBy(ItemId)
.static <T extends ItemInfo>
java.util.function.Predicate<T>disabledBy(ItemId scope)
Filter for items disabled in specified scope.static <T extends ItemInfo>
java.util.function.Predicate<T>enabled()
Filter for enabled items.static java.util.function.Predicate<ExtensionItemInfo>
fromBinding()
Filter for extensions detected from guice bindings.static <T extends ItemInfo>
java.util.function.Predicate<T>fromScan()
Filter for items registered with classpath scan.static java.util.function.Predicate<ExtensionItemInfo>
installedBy(java.lang.Class<? extends FeatureInstaller> type)
Filter for extensions installed by specified installer.static java.util.function.Predicate<GuiceyBundleItemInfo>
lookupBundles()
Filter for bundles resolved by lookup mechanism.static java.util.function.Predicate<ModuleItemInfo>
overridingModule()
Filter for overriding modules.static <T extends ItemInfo>
java.util.function.Predicate<T>registeredBy(java.lang.Class<?> type)
Shortcut forregisteredBy(ItemId)
for scope classes.static <T extends ItemInfo>
java.util.function.Predicate<T>registeredBy(ConfigScope specialScope)
Shortcut forregisteredBy(ItemId)
for special scopes (like classpath scan, bundles lookup etc).static <T extends ItemInfo>
java.util.function.Predicate<T>registeredBy(ItemId scope)
In contrast toregistrationScope(ItemId)
this filter returns item for all scopes mentioned item (including scopes where registration was considered duplicate).static <T extends ItemInfo>
java.util.function.Predicate<T>registrationScope(java.lang.Class<?> type)
Shortcut forregistrationScope(ItemId)
.static <T extends ItemInfo>
java.util.function.Predicate<T>registrationScope(ConfigScope specialScope)
Shortcut forregistrationScope(ItemId)
for special scopes (like classpath scan, bundles lookup etc).static <T extends ItemInfo>
java.util.function.Predicate<T>registrationScope(ItemId scope)
Filter for items registered by specified context.static java.util.function.Predicate<BundleItemInfo>
transitiveBundles()
Filter for transitive bundles: bundles registered only by other bundles (and never directly).static <T extends ItemInfo>
java.util.function.Predicate<T>type(java.lang.Class<?> type)
Filter used for instance items (bundle, module) selection by type.static <T extends ItemInfo>
java.util.function.Predicate<T>type(ConfigItem... types)
Filter used for multi-type searches to filter out item types.
-
-
-
Method Detail
-
enabled
public static <T extends ItemInfo> java.util.function.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
-
disabledBy
public static <T extends ItemInfo> java.util.function.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> java.util.function.Predicate<T> disabledBy(java.lang.Class<?> type)
Shortcut fordisabledBy(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> java.util.function.Predicate<T> fromScan()
Filter for items registered with classpath scan. Not all items support classpath scanScanSupport
. 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> java.util.function.Predicate<T> registrationScope(ItemId scope)
Filter for items registered by specified context. Context class could beApplication
,ClasspathScanner
,GuiceyBundleLookup
and classes implementingGuiceyBundle
. 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:
for the list of all special scopes
-
registrationScope
public static <T extends ItemInfo> java.util.function.Predicate<T> registrationScope(ConfigScope specialScope)
Shortcut forregistrationScope(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> java.util.function.Predicate<T> registrationScope(java.lang.Class<?> type)
Shortcut forregistrationScope(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> java.util.function.Predicate<T> registeredBy(ItemId scope)
In contrast toregistrationScope(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:
for the list of all special scopes
-
registeredBy
public static <T extends ItemInfo> java.util.function.Predicate<T> registeredBy(ConfigScope specialScope)
Shortcut forregisteredBy(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> java.util.function.Predicate<T> registeredBy(java.lang.Class<?> type)
Shortcut forregisteredBy(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> java.util.function.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 withPredicate.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> java.util.function.Predicate<T> type(java.lang.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 java.util.function.Predicate<GuiceyBundleItemInfo> lookupBundles()
Filter for bundles resolved by lookup mechanism. Use only forConfigItem.Bundle
items.- Returns:
- bundles resolved by lookup filter
-
transitiveBundles
public static java.util.function.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> java.util.function.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)
-
installedBy
public static java.util.function.Predicate<ExtensionItemInfo> installedBy(java.lang.Class<? extends FeatureInstaller> type)
Filter for extensions installed by specified installer. Use only forConfigItem.Extension
items.- Parameters:
type
- installer class- Returns:
- extensions installed by specified installer filter
-
fromBinding
public static java.util.function.Predicate<ExtensionItemInfo> fromBinding()
Filter for extensions detected from guice bindings. Use only forConfigItem.Extension
items.- Returns:
- extensions resolved from binding filter
-
overridingModule
public static java.util.function.Predicate<ModuleItemInfo> overridingModule()
Filter for overriding modules. Use only forConfigItem.Module
items.- Returns:
- overriding modules filter
-
-