Class ConfigurationInfo
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.context.ConfigurationInfo
-
public final class ConfigurationInfo extends java.lang.Object
Public api for collected guicey configuration info. In contrast toConfigurationContext
, 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:
as high level info api
,for the list of available confiugration items
-
-
Constructor Summary
Constructors Constructor Description ConfigurationInfo(ConfigurationContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends ItemInfo>
TgetInfo(ItemId id)
NOTE: it will not return first instance of type if called asgetInfo(ItemId.from(Bundle.class)))
!<T extends ItemInfo>
java.util.List<T>getInfos(java.lang.Class<?> type)
Returns all registrations of type.java.util.List<ItemId<java.lang.Object>>
getItems(java.lang.Class<?> type)
java.util.List<ItemId<java.lang.Object>>
getItems(java.util.function.Predicate<? extends ItemInfo> filter)
Used to query items of all configuration types.<T> java.util.List<ItemId<T>>
getItems(ConfigItem type)
Pay attention that disabled (or disabled and never registered) items are also returned.<T,K extends ItemInfo>
java.util.List<ItemId<T>>getItems(ConfigItem type, java.util.function.Predicate<K> filter)
Used to query items of one configuration type (e.g. only installers or bundles).
-
-
-
Constructor Detail
-
ConfigurationInfo
public ConfigurationInfo(ConfigurationContext context)
-
-
Method Detail
-
getItems
public <T> java.util.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> java.util.List<ItemId<T>> getItems(ConfigItem type, java.util.function.Predicate<K> filter)
Used to query items of one configuration type (e.g. only installers or bundles). Some common filters are predefined inFilters
. UsePredicate.and(Predicate)
,Predicate.or(Predicate)
andPredicate.negate()
to reuse default filters.Pay attention that disabled (or disabled and never registered) items are also returned.
- Type Parameters:
T
- expected classK
- expected info container class- Parameters:
type
- configuration item typefilter
- predicate to filter definitions- Returns:
- registered item ids in registration order, filtered with provided filter or empty list
-
getItems
public java.util.List<ItemId<java.lang.Object>> getItems(java.util.function.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 inFilters
. UsePredicate.and(Predicate)
,Predicate.or(Predicate)
andPredicate.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 java.util.List<ItemId<java.lang.Object>> getItems(java.lang.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 asgetInfo(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 idItemId.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:
to retrieve all instace items of type
-
getInfos
public <T extends ItemInfo> java.util.List<T> getInfos(java.lang.Class<?> type)
Returns all registrations of type. For class based extensions will return list of one element (the same result asgetInfo(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
-
-