I
- the type of Individualpublic class AbstractIndividualFactory<I extends Individual> extends java.lang.Object implements IndividualFactory
AbstractIndividualFactory
creates Individual
s using a
given Provider
and sets the registered
IndividualStateListener
s. The Creator
is used to create the
problem specific Genotype
with which the created Individual
is initialized.Modifier and Type | Field and Description |
---|---|
protected Creator<Genotype> |
creator |
protected com.google.inject.Provider<I> |
individualProvider |
protected java.util.Set<IndividualStateListener> |
individualStateListeners |
Constructor and Description |
---|
AbstractIndividualFactory(com.google.inject.Provider<I> individualProvider,
Creator<Genotype> creator)
|
Modifier and Type | Method and Description |
---|---|
void |
addIndividualStateListener(IndividualStateListener listener)
Adds an
IndividualStateListener to each Individual that
is created by this class. |
Individual |
create()
Creates a new
Individual . |
Individual |
create(Genotype genotype)
Creates a new
Individual with a specified Genotype . |
protected void |
injectListeners(java.util.Set<IndividualStateListener> listeners)
The
IndividualStateListener s will be transmitted to each
Individual that is created by this class. |
void |
removeIndividualStateListener(IndividualStateListener listener)
Removes an
IndividualStateListener that is invoked if the state
of any Individual changes. |
protected final com.google.inject.Provider<I extends Individual> individualProvider
protected final java.util.Set<IndividualStateListener> individualStateListeners
@Inject protected void injectListeners(java.util.Set<IndividualStateListener> listeners)
IndividualStateListener
s will be transmitted to each
Individual
that is created by this class. The listeners are
invoked if the state of the Individual
changes.listeners
- the listenerspublic void addIndividualStateListener(IndividualStateListener listener)
IndividualFactory
IndividualStateListener
to each Individual
that
is created by this class. This listener is invoked if the state of the
Individual
changes.addIndividualStateListener
in interface IndividualFactory
listener
- the listener that is invoked if the state of any individual
changesIndividualFactory.removeIndividualStateListener(org.opt4j.core.IndividualStateListener)
public Individual create()
IndividualFactory
Individual
.create
in interface IndividualFactory
public Individual create(Genotype genotype)
IndividualFactory
Individual
with a specified Genotype
.create
in interface IndividualFactory
genotype
- the genotype of the individualpublic void removeIndividualStateListener(IndividualStateListener listener)
IndividualFactory
IndividualStateListener
that is invoked if the state
of any Individual
changes. All Individual
s created after
this method call by this IndividualFactory
do no longer use the
listener.removeIndividualStateListener
in interface IndividualFactory
listener
- the listener that is invoked if the state of any individual
changesIndividualFactory.addIndividualStateListener(org.opt4j.core.IndividualStateListener)