Class UniqueItemsDuplicatesDetector
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.context.unique.UniqueItemsDuplicatesDetector
-
- All Implemented Interfaces:
DuplicateConfigDetector
public class UniqueItemsDuplicatesDetector extends java.lang.Object implements DuplicateConfigDetector
Simple deduplicator implementation to track uniqueness for exact items (not everything likeLegacyModeDuplicatesDetector
do).- Since:
- 24.09.2019
-
-
Constructor Summary
Constructors Constructor Description UniqueItemsDuplicatesDetector(java.lang.Class<?>... uniqueItems)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getDuplicateItem(java.util.List<java.lang.Object> registered, java.lang.Object newItem)
Called every time when configured object (guicey bundle or guice module) of the same type is already registered.
-
-
-
Method Detail
-
getDuplicateItem
public java.lang.Object getDuplicateItem(java.util.List<java.lang.Object> registered, java.lang.Object newItem)
Description copied from interface:DuplicateConfigDetector
Called 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:
getDuplicateItem
in 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)
-
-