Package org.moeaframework.core.spi
Class AbstractFactory<T>
java.lang.Object
org.moeaframework.core.spi.AbstractFactory<T>
- Type Parameters:
T
- the generic type of the provider
- All Implemented Interfaces:
Iterable<T>
- Direct Known Subclasses:
AlgorithmFactory
,OperatorFactory
,ProblemFactory
Abstract factory for service providers. This contains convenience methods for enumerating the providers using a
ServiceLoader
along with explicit providers registered with addProvider(T)
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addProvider
(T provider) Adds a provider to this factory.boolean
hasProvider
(String name) Returnstrue
if this factory contains a provider with the given name.iterator()
Returns an iterator of all registered providers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AbstractFactory
Constructs a new factory for the given type.- Parameters:
type
- the class of the provider
-
-
Method Details
-
addProvider
Adds a provider to this factory. Subsequent calls to enumerate the providers will include this provider.- Parameters:
provider
- the new provider
-
iterator
Returns an iterator of all registered providers. -
hasProvider
Returnstrue
if this factory contains a provider with the given name. This will match either the class' fully-qualified name or simple name.- Parameters:
name
- the class name, either simple or including the package- Returns:
true
if this factory contains the provider;false
otherwise
-