Class ItemInfoImpl
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.context.info.impl.ItemInfoImpl
-
- All Implemented Interfaces:
ItemInfo
- Direct Known Subclasses:
ClassItemInfoImpl,InstanceItemInfoImpl
public class ItemInfoImpl extends java.lang.Object implements ItemInfo
Item info implementation.- Since:
- 06.07.2016
-
-
Constructor Summary
Constructors Constructor Description ItemInfoImpl(ConfigItem itemType, ItemId id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcountRegistrationAttempt(ItemId scope)ItemIdgetId()Items could be registered by class and by instance.intgetIgnoresByScope(java.lang.Class<?> scope)Shortcut forItemInfo.getIgnoresByScope(ItemId).intgetIgnoresByScope(ItemId scope)Required to show ignored items in the same scope as actual registration.ConfigItemgetItemType()java.util.Set<ItemId>getRegisteredBy()Configuration items may be registered by root application class, classpath scan or guicey bundle.intgetRegistrationAttempts()It may be 0 for disabled items (e.g. installer disabled but never registered).ItemIdgetRegistrationScope()Item may be registered multiple times.ConfigScopegetRegistrationScopeType()It is essentially the same asItemInfo.getRegistrationScope(), but with generified guicey bundle scope.java.lang.Class<?>getType()booleanisRegistered()Useful to recognize not registered info items appeared for example because of item disabling.booleanisRegisteredDirectly()java.lang.StringtoString()
-
-
-
Constructor Detail
-
ItemInfoImpl
public ItemInfoImpl(ConfigItem itemType, ItemId id)
-
-
Method Detail
-
getId
public ItemId getId()
Description copied from interface:ItemInfoItems could be registered by class and by instance. In case of instance registration, multiple instances could be provided with the same class. For class registrations item id is equal to pure class.
-
getItemType
public ConfigItem getItemType()
- Specified by:
getItemTypein interfaceItemInfo- Returns:
- configuration item type (e.g. installer, bundle, extension etc)
-
getType
public java.lang.Class<?> getType()
-
getRegisteredBy
public java.util.Set<ItemId> getRegisteredBy()
Description copied from interface:ItemInfoConfiguration items may be registered by root application class, classpath scan or guicey bundle. For registrations in application classApplicationis stored as context. For registration by classpath scanClasspathScanneris stored as context. For registrations byGuiceyBundle, actual bundle class is stored as context. Bundle items may also haveGuiceyBundleLookupas context classe for bundles resolved by lookup mechanism.May not contain elements if item was never registered, but for example, disabled.
To quick check if exact scope class is present use
ItemId.from(class), which will match any class instance related scope key.- Specified by:
getRegisteredByin interfaceItemInfo- Returns:
- context classes which register item or empty collection
- See Also:
for the list of all special scopes
-
getRegistrationAttempts
public int getRegistrationAttempts()
Description copied from interface:ItemInfoIt may be 0 for disabled items (e.g. installer disabled but never registered). Also, count may be greater than registration sources count, because the same source could register item multiple times.- Specified by:
getRegistrationAttemptsin interfaceItemInfo- Returns:
- count of item registrations
-
isRegistered
public boolean isRegistered()
Description copied from interface:ItemInfoUseful to recognize not registered info items appeared for example because of item disabling.- Specified by:
isRegisteredin interfaceItemInfo- Returns:
- true if item was registered, false otherwise
-
isRegisteredDirectly
public boolean isRegisteredDirectly()
- Specified by:
isRegisteredDirectlyin interfaceItemInfo- Returns:
- true if item directly registered through
GuiceBundle.Builder, false otherwise.
-
getRegistrationScope
public ItemId getRegistrationScope()
Description copied from interface:ItemInfoItem may be registered multiple times. For class items (e.g. extension) only first scope will be actual registration scope (and registrations from other scopes will be simply ignored). For instance items (bundle, module), different objects of the same type will be registered according toDuplicateConfigDetector).May be null for never registered but disabled items!
- Specified by:
getRegistrationScopein interfaceItemInfo- Returns:
- registration scope
- See Also:
for all scopes performing registratoin
-
getRegistrationScopeType
public ConfigScope getRegistrationScopeType()
Description copied from interface:ItemInfoIt is essentially the same asItemInfo.getRegistrationScope(), but with generified guicey bundle scope. May be useful for generic reporting.- Specified by:
getRegistrationScopeTypein interfaceItemInfo- Returns:
- type of registration scope
-
getIgnoresByScope
public int getIgnoresByScope(ItemId scope)
Description copied from interface:ItemInfoRequired to show ignored items in the same scope as actual registration.When checked bundles by class only item (
ItemId.from(Bundle.class)) it wil return sum of registrations for all instances of type.- Specified by:
getIgnoresByScopein interfaceItemInfo- Parameters:
scope- scope- Returns:
- number of ignored items in scope
-
getIgnoresByScope
public int getIgnoresByScope(java.lang.Class<?> scope)
Description copied from interface:ItemInfoShortcut forItemInfo.getIgnoresByScope(ItemId).- Specified by:
getIgnoresByScopein interfaceItemInfo- Parameters:
scope- scope type to check ignores- Returns:
- number of ignored items in all scopes of specified type
-
countRegistrationAttempt
public void countRegistrationAttempt(ItemId scope)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-