@MetaInfServices public class BasicFactoryLookupStrategy extends Object implements FactoryLookupStrategy
Concrete FactoryLookupStrategy that implements the following Factory lookup algorithm:
| Constructor and Description |
|---|
BasicFactoryLookupStrategy(FactoryCollection factoryCollection,
RandomValueGenerator randomValueGenerator)
Construct a new Factory Lookup Strategy.
|
| Modifier and Type | Method and Description |
|---|---|
Factory<?> |
getFactory(BeanInformation beanInformation,
PropertyInformation propertyInformation,
Configuration configuration)
Get a factory for the specified property that is of the specified type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInstance, getServiceDefinitionpublic BasicFactoryLookupStrategy(FactoryCollection factoryCollection, RandomValueGenerator randomValueGenerator) throws IllegalArgumentException
factoryCollection - A collection of test data Factories.randomValueGenerator - Random number generator used by factories to randomly generate values.IllegalArgumentException - If either the factoryCollection or randomValueGenerator are deemed illegal. For example, if either is
null.public Factory<?> getFactory(BeanInformation beanInformation, PropertyInformation propertyInformation, Configuration configuration) throws IllegalArgumentException, NoSuchFactoryException
Get a factory for the specified property that is of the specified type.
If a Configuration is provided, this is first inspected for a property-specific Factory.
If no Configuration is provided or there is no property-specific Factory in the Configuration, the
FactoryCollection is then searched for a Factory suitable for the type of the property.
If the FactoryCollection does not contain a suitable Factory, an attempt is made to create a Factory for the type.
For example, if the type is an Enum, then a generic Enum Factory will be created for the Enum's constants,
registered in the Factory Collection for future use, and returned from this method.
As a last resort, an attempt is made create a Factory that creates objects of the custom data type. If
successful, this Factory is registered in the Factory Collection for future use, and return from this method.
If ultimately a suitable Factory cannot be found or created, a NoSuchFactoryException detailing the problem is thrown.
getFactory in interface FactoryLookupStrategybeanInformation - Information about the bean the property belongs to.propertyInformation - The information of the property.configuration - An optional Configuration object that may contain an override Factory for the specified property. Pass
null if no Configuration exists.IllegalArgumentException - If any of the required parameters are deemed illegal. For example, if any are null.NoSuchFactoryException - If an unexpected exception occurs when getting the Factory, including failing to find a suitable
Factory.Copyright © 2010–2020 meanbean. All rights reserved.