java.lang.Object
com.aoapps.collections.PolymorphicRegistry<U>
A registry of objects by their class, along with all their parent classes
and interfaces, up to and including an upper bound. The registry is highly
concurrent, and performs registry lookups in O(1).
- Author:
- AO Industries, Inc.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a instance to the registry.Gets all instances registered of the given class.Gets all instances registered of the given class that match the given filter.<T extends U>
TGets the first instance registered of the given class.<T extends U>
TGets the first instance registered of the given class that match the given filter.<T extends U>
TGets the last instance registered of the given class.<T extends U>
TGets the last instance registered of the given class that match the given filter.
-
Constructor Details
-
PolymorphicRegistry
-
-
Method Details
-
add
Adds a instance to the registry. The instance is registered underall classes and interfaces
it extends and implements, up to and including the upper boundU
.This implementation favors lookup speed at O(1), and pays the price during
add(java.lang.Object)
. -
get
Gets all instances registered of the given class. They are returned in the order registered. When an object is registered more than once, it will appear in the list multiple times. The list is a snapshot and will not change over time.- Returns:
- the unmodifiable list of all objects registered of the given class, or an empty list when none registered
-
get
Gets all instances registered of the given class that match the given filter. They are returned in the order registered. When an object is registered more than once, it will appear in the list multiple times. The list is a snapshot and will not change over time.- Returns:
- the unmodifiable list of all objects registered of the given class that match the filter, or an empty list when none registered
-
getFirst
Gets the first instance registered of the given class.- Returns:
- the first instance registered or
null
for none registered
-
getFirst
Gets the first instance registered of the given class that match the given filter.- Returns:
- the first instance registered that matches the filter or
null
for none registered
-
getLast
Gets the last instance registered of the given class.- Returns:
- the last instance registered or
null
for none registered
-
getLast
Gets the last instance registered of the given class that match the given filter.- Returns:
- the last instance registered that matches the filter or
null
for none registered
-