Package arez.component
Class TypeBasedLocator
java.lang.Object
arez.component.TypeBasedLocator
- All Implemented Interfaces:
Locator
@OmitType(unless="arez.enable_references")
public final class TypeBasedLocator
extends Object
implements Locator
An Locator implementation where you can register a function-per type to be resolved.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
Lookup the entity with the specified type and the specified id, returning null if not present.<T> void
registerLookup
(Class<T> type, Function<Object, T> findByIdFunction) Register a function that will find entities of specified type by id.
-
Constructor Details
-
TypeBasedLocator
public TypeBasedLocator()
-
-
Method Details
-
registerLookup
public <T> void registerLookup(@Nonnull Class<T> type, @Nonnull Function<Object, T> findByIdFunction) Register a function that will find entities of specified type by id. This must not be invoked if another function has already been registered for type.- Type Parameters:
T
- the type of the entity.- Parameters:
type
- the type of the entity.findByIdFunction
- the function that looks up the entity by id.
-
findById
Description copied from interface:Locator
Lookup the entity with the specified type and the specified id, returning null if not present.
-