@Order(value=8000) @MetaInfServices public final class FactoryRepository extends Object implements FactoryCollection
| Constructor and Description |
|---|
FactoryRepository() |
| Modifier and Type | Method and Description |
|---|---|
void |
addFactory(Class<?> clazz,
Factory<?> factory)
Add the specified Factory to the collection.
|
void |
addFactoryLookup(FactoryLookup factoryLookup)
Add the specified FactoryLookup
|
<T> Factory<T> |
getFactory(Type type)
Get the Factory registered for the specified class.
|
RandomValueGenerator |
getRandomValueGenerator()
Get a RandomNumberGenerator.
|
boolean |
hasFactory(Type type)
Does the collection contain a Factory registered against the specified class?
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInstance, getServiceDefinitiongetFactoryIfAvailablepublic FactoryRepository()
throws IllegalArgumentException
IllegalArgumentExceptionpublic RandomValueGenerator getRandomValueGenerator()
public void addFactory(Class<?> clazz, Factory<?> factory) throws IllegalArgumentException
Add the specified Factory to the collection.
If a Factory is already registered against the specified class, the existing registered Factory will be replaced with the Factory you specify here.
addFactory in interface FactoryCollectionclazz - The type of objects the Factory creates. The class type will be used to generate a key with which the
Factory can be retrieved from the collection at a later stage.factory - The Factory to add to the collection.IllegalArgumentException - If either of the required parameters are deemed illegal.public void addFactoryLookup(FactoryLookup factoryLookup)
FactoryCollectionAdd the specified FactoryLookup
The factoryLookup will be first consulted when looking for a FactoryaddFactoryLookup in interface FactoryCollectionpublic <T> Factory<T> getFactory(Type type) throws IllegalArgumentException, NoSuchFactoryException
Get the Factory registered for the specified class.
To check whether a Factory is registered for a specified class, please refer to
hasFactory(Class<?> clazz);.
getFactory in interface FactoryLookuptype - The type Factory is registered against. This should be the type of object that the Factory
creates.IllegalArgumentException - If the class is deemed illegal.NoSuchFactoryException - If the collection does not contain a Factory registered against the specified class.public boolean hasFactory(Type type) throws IllegalArgumentException
hasFactory in interface FactoryLookuptype - The type a Factory could be registered against. This should be the type of object that the Factory
creates.true if the collection contains a Factory registered for the specified class;
false otherwise.IllegalArgumentException - If the clazz is deemed illegal.Copyright © 2010–2020 meanbean. All rights reserved.