public class FactoryCollectionImpl extends Object implements FactoryCollection
FactoryCollection interface. Note
that this implementation is not thread-safe.| Constructor and Description |
|---|
FactoryCollectionImpl() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canInstantiate(Configuration conf)
This method tests whether the supplied
Configuration can be
instantiated into an object by this factory. |
Object |
create(Configuration conf,
Dependencies dependencies)
Creates a new instance based on the provided
Configuration. |
void |
register(Factory f)
Registers a new factory for this collection.
|
void |
replace(Configuration configuration,
Factory<?,?,?> replacement)
Attempts to find a factory in this collection, which is capable of
instantiating the provided configuration.
|
public boolean canInstantiate(Configuration conf)
Factory
This method tests whether the supplied Configuration can be
instantiated into an object by this factory.
canInstantiate in interface Factory<Object,Configuration,Dependencies>conf - A configuration for an object to be instantiated.true when this factory can create an instance for
the provided configuration.public Object create(Configuration conf, Dependencies dependencies)
Factory
Creates a new instance based on the provided Configuration.
Run-time dependencies can be provided through the dependencies type for this factory.
create in interface Factory<Object,Configuration,Dependencies>conf - The configuration used to instantiate the object.dependencies - Run-time dependencies for this object.public void register(Factory f)
FactoryCollectionRegisters a new factory for this collection.
If a
The collection will always use the first factory registered to
instantate objects. Configuration compatible with this factory is passed to
subsequent calls of FactoryCollection#create(Configuration,
Dependencies), this factory will be used to instantiate the object.
register in interface FactoryCollectionf - The factory to be added to the collection.public void replace(Configuration configuration, Factory<?,?,?> replacement)
FactoryCollectionAttempts to find a factory in this collection, which is capable of instantiating the provided configuration.
If such a factory is found, it is replaced with the provided factory.
replace in interface FactoryCollectionCopyright © 2018. All rights reserved.