Package org.opt4j.core
Class AbstractIndividualFactory<I extends Individual>
- java.lang.Object
-
- org.opt4j.core.AbstractIndividualFactory<I>
-
- Type Parameters:
I- the type of Individual
- All Implemented Interfaces:
IndividualFactory
- Direct Known Subclasses:
DefaultIndividualFactory,ParticleFactory
public class AbstractIndividualFactory<I extends Individual> extends Object implements IndividualFactory
TheAbstractIndividualFactorycreatesIndividuals using a givenProviderand sets the registeredIndividualStateListeners. TheCreatoris used to create the problem specificGenotypewith which the createdIndividualis initialized.
-
-
Field Summary
Fields Modifier and Type Field Description protected Creator<Genotype>creatorprotected com.google.inject.Provider<I>individualProviderprotected Set<IndividualStateListener>individualStateListeners
-
Constructor Summary
Constructors Constructor Description AbstractIndividualFactory(com.google.inject.Provider<I> individualProvider, Creator creator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddIndividualStateListener(IndividualStateListener listener)Adds anIndividualStateListenerto eachIndividualthat is created by this class.Individualcreate()Creates a newIndividual.Individualcreate(Genotype genotype)Creates a newIndividualwith a specifiedGenotype.protected voidinjectListeners(Set<IndividualStateListener> listeners)TheIndividualStateListeners will be transmitted to eachIndividualthat is created by this class.voidremoveIndividualStateListener(IndividualStateListener listener)Removes anIndividualStateListenerthat is invoked if the state of anyIndividualchanges.
-
-
-
Field Detail
-
individualProvider
protected final com.google.inject.Provider<I extends Individual> individualProvider
-
individualStateListeners
protected final Set<IndividualStateListener> individualStateListeners
-
-
Method Detail
-
injectListeners
@Inject protected void injectListeners(Set<IndividualStateListener> listeners)
TheIndividualStateListeners will be transmitted to eachIndividualthat is created by this class. The listeners are invoked if the state of theIndividualchanges.- Parameters:
listeners- the listeners
-
addIndividualStateListener
public void addIndividualStateListener(IndividualStateListener listener)
Description copied from interface:IndividualFactoryAdds anIndividualStateListenerto eachIndividualthat is created by this class. This listener is invoked if the state of theIndividualchanges.- Specified by:
addIndividualStateListenerin interfaceIndividualFactory- Parameters:
listener- the listener that is invoked if the state of any individual changes- See Also:
IndividualFactory.removeIndividualStateListener(org.opt4j.core.IndividualStateListener)
-
create
public Individual create()
Description copied from interface:IndividualFactoryCreates a newIndividual.- Specified by:
createin interfaceIndividualFactory- Returns:
- the built individual
-
create
public Individual create(Genotype genotype)
Description copied from interface:IndividualFactoryCreates a newIndividualwith a specifiedGenotype.- Specified by:
createin interfaceIndividualFactory- Parameters:
genotype- the genotype of the individual- Returns:
- the built individual
-
removeIndividualStateListener
public void removeIndividualStateListener(IndividualStateListener listener)
Description copied from interface:IndividualFactoryRemoves anIndividualStateListenerthat is invoked if the state of anyIndividualchanges. AllIndividuals created after this method call by thisIndividualFactorydo no longer use the listener.- Specified by:
removeIndividualStateListenerin interfaceIndividualFactory- Parameters:
listener- the listener that is invoked if the state of any individual changes- See Also:
IndividualFactory.addIndividualStateListener(org.opt4j.core.IndividualStateListener)
-
-