Class UniqueItemsDuplicatesDetector
java.lang.Object
ru.vyarus.dropwizard.guice.module.context.unique.UniqueItemsDuplicatesDetector
- All Implemented Interfaces:
DuplicateConfigDetector
Simple deduplicator implementation to track uniqueness for exact items (not everything like
LegacyModeDuplicatesDetector do).- Since:
- 24.09.2019
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDuplicateItem(List<Object> registered, Object newItem) Called every time when configured object (guicey bundle or guice module) of the same type is already registered.
-
Constructor Details
-
UniqueItemsDuplicatesDetector
Create detector.- Parameters:
uniqueItems- unique items
-
-
Method Details
-
getDuplicateItem
Description copied from interface:DuplicateConfigDetectorCalled every time when configured object (guicey bundle or guice module) of the same type is already registered. Note that method is called only if new instance is not equal to any registered instances of the same type. Method must return duplicate object from already registered instances (or null to allow new registration).For example, if 3 or more instances of the same type are registered then method would be called for each new configured instance (in case of 3 registrations - 2 method calls, assuming that instances are not equal).
Provided instances will always be of the same class (no polymorphic checks). Classes loaded from different class loaders will be recognized as same class (and so provided instances may be instances of the same class but from different class loaders).
- Specified by:
getDuplicateItemin interfaceDuplicateConfigDetector- Parameters:
registered- already registered itemsnewItem- new item to check- Returns:
- duplicate object from already registered (to mark this one as duplicate to already registered)
-