com.rubecula.darwin.domain.world
Class Taxon_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.foundation.Evolvable_
          extended by com.rubecula.darwin.domain.world.Taxon_
All Implemented Interfaces:
Censusible, HasPhenotypeCache, Registry, Taxon, Evolvable, Generational, Terminal, Theological, net.sf.tostring0.Identifiable, net.sf.tostring0.IToString
Direct Known Subclasses:
Taxon_Darwinian

public abstract class Taxon_
extends Evolvable_
implements Taxon

Abstract class implementing Taxon interface.

Author:
Robin Hillyard

Field Summary
protected  Census _censusTaker
          The census taker which implements the Census in order to make a census of this Taxon.
protected  Genomic _genomic
          The Genomic of this Taxon (fixed).
protected  Mortality _mortality
          The "Grim Reaper" which implements the Mortality to determine when organisms in this system will die.
protected  Phenome _phenome
          The Phenome of this Taxon (fixed).
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
Fields inherited from interface net.sf.tostring0.IToString
ANGBR_OPEN, ANGBRA_CLSE, BRA_CLSE, BRA_OPEN, BRCE_OPEN, BRCS_CLSE, COLON, LIST_SEPARATOR, MAX_ELEMENTS_DEFAULT, S_MT, S_PERCENT, SEPARATOR, SPACE
 
Constructor Summary
protected Taxon_(java.lang.String identifier, Realm realm, Genomic genomic, Phenome phenome, Census censusTaker, Mortality mortality, MateChoice chooser, Fecundity fecundity)
          Constructor to create a Taxon with no populations.
 
Method Summary
 int addPopulation(Population population)
          Add the given population to this Taxon.
 void addVisualizableListener(VisualizableListener listener)
          XXX
 boolean censusMe(Census census, java.lang.Object prefix)
          Method to census this object.
 void cullMembers()
          For each population, call Theological.cullMembers(), passing value of organisms.
 void doCensus()
          XXX this is currently only ever used by tests.
 boolean equals(java.lang.Object obj)
           
 java.util.Collection<? extends Censusible> getCensusibleChildren()
          Method to return a list of censusible children of this object.
 Census getCensusTaker()
          XXX
 MateChoice getChooser()
          XXX
 Fecundity getFecundity()
          XXX
 Genomic getGenomic()
          XXX
 java.lang.String getIdentifier()
           
 Mortality getMortality()
           
 Phenome getPhenome()
          XXX
 PhenotypeCache getPhenotypeCache()
           
 Population getPopulation(int index)
          TODO this method should be eliminated.
 java.util.Collection<Population> getPopulations()
          TODO this method should get the apporpriate populations from this taxon's Realm.
 java.util.Map<java.lang.String,java.lang.Object> getProperties()
          Bean method.
 java.lang.Object getProperty(java.lang.Object key)
          Method to get one of the arbitrary application-specific properties of this system.
 Realm getRealm()
           
 int getSeedPopulation()
           
 java.util.Collection<VisualizableListener> getVisualizableListeners()
          Getter/setter typically called by reflection.
 int hashCode()
           
 boolean isFinished()
          First we check the super-method.
 boolean isLastGeneration()
          TODO consider combining this with isFinished().
 boolean nextGeneration()
          For each population in this system, call nextGeneration().
 void registerBirths(Colony colony, java.util.Collection<Organism> neonates)
          TODO consider changing parameter to Colony
 void registerDeaths(Colony colony, java.util.Collection<Organism> deaths)
          TEST
 void registerMarriages(Colony colony, java.util.Collection<Mating> marriages)
           
 void seedMembers()
          For each population, call Theological.seedMembers(), passing value of organisms.
 void setPopulations(java.util.Collection<Population> populations)
          This is the preferred way to set populations, rather than using the addPopulation(Population) method.
 void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
          Bean method.
 java.lang.Object setProperty(java.lang.String key, java.lang.Object value)
          method to set one of the arbitrary application-specific properties of this system.
 void setRegistry(Registry registry)
          Invoked via bean operations (e.g dependency injection)
 void setSeedPopulation(int seedPopulation)
           
 void setVisualizableListeners(java.util.Collection<VisualizableListener> visualizableListeners)
          This is called, but not addListener()
 
Methods inherited from class com.rubecula.darwin.foundation.Evolvable_
getGeneration, getMaxGenerations, getResult, setMaxGenerations, setResult
 
Methods inherited from class net.sf.tostring0.AToString
toString, toString, toStringBrief, toStringId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rubecula.darwin.foundation.Evolvable
getGeneration, getResult
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
The logger for this class.


_censusTaker

protected final Census _censusTaker
The census taker which implements the Census in order to make a census of this Taxon.


_genomic

protected final Genomic _genomic
The Genomic of this Taxon (fixed).


_mortality

protected final Mortality _mortality
The "Grim Reaper" which implements the Mortality to determine when organisms in this system will die.


_phenome

protected final Phenome _phenome
The Phenome of this Taxon (fixed).

Constructor Detail

Taxon_

protected Taxon_(java.lang.String identifier,
                 Realm realm,
                 Genomic genomic,
                 Phenome phenome,
                 Census censusTaker,
                 Mortality mortality,
                 MateChoice chooser,
                 Fecundity fecundity)
Constructor to create a Taxon with no populations.

Parameters:
identifier - the identifier for this new system.
realm - the realm in which this system can be found.
genomic - the genomic object on which the genomes of all organisms in all populations of this new system will be based.
phenome - the phenome which all organisms of all populations of this new system will exhibit.
censusTaker - an implementer of Census for the purpose of censusing populations of the new system.
mortality - an implementer of Mortality for the purpose of calculating mortalities of organims in populations of this new system.
chooser - the mate chooser.
fecundity - the fecundity determiner.
Method Detail

addPopulation

public int addPopulation(Population population)
Add the given population to this Taxon. There are two side-effects: this is passed to the population's setSystem() method; and the index of the population in the list of _populations is passed to the population's setIndex() method.

Specified by:
addPopulation in interface Taxon
Parameters:
population - an implementer of Population.
Returns:
true if the population was added successfully.
See Also:
Taxon.addPopulation(com.rubecula.darwin.domain.helper.Population)

addVisualizableListener

public void addVisualizableListener(VisualizableListener listener)
XXX

Specified by:
addVisualizableListener in interface Taxon
Parameters:
listener - the listener of population change events.
See Also:
Taxon.addVisualizableListener(com.rubecula.darwin.foundation.VisualizableListener)

censusMe

public boolean censusMe(Census census,
                        java.lang.Object prefix)
Description copied from interface: Censusible
Method to census this object.

Specified by:
censusMe in interface Censusible
Parameters:
census -
prefix - for error message only
Returns:
true if we should continue censusing this object at deeper levels. If the result is false, then we do not call Censusible.getCensusibleChildren().
See Also:
Censusible.censusMe(Census, java.lang.Object)

cullMembers

public void cullMembers()
For each population, call Theological.cullMembers(), passing value of organisms.

Specified by:
cullMembers in interface Theological
See Also:
Theological.seedMembers()

doCensus

public void doCensus()
              throws java.io.IOException
XXX this is currently only ever used by tests.

Specified by:
doCensus in interface Taxon
Throws:
java.io.IOException
See Also:
Taxon.doCensus()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class Evolvable_
See Also:
Evolvable_.equals(java.lang.Object)

getCensusibleChildren

public java.util.Collection<? extends Censusible> getCensusibleChildren()
Description copied from interface: Censusible
Method to return a list of censusible children of this object.

Specified by:
getCensusibleChildren in interface Censusible
Returns:
either null or an ArrayList of censusible objects.
See Also:
Censusible.getCensusibleChildren()

getCensusTaker

public Census getCensusTaker()
XXX

Specified by:
getCensusTaker in interface Taxon
Returns:
the application-specific implementer of Census.
See Also:
Taxon.getCensusTaker()

getChooser

public MateChoice getChooser()
XXX

Specified by:
getChooser in interface Taxon
Returns:
the application-specific implementer of MateChoice.
See Also:
Taxon.getChooser()

getFecundity

public Fecundity getFecundity()
XXX

Specified by:
getFecundity in interface Taxon
Returns:
the application-specific implementer of Fecundity.
See Also:
Taxon.getFecundity()

getGenomic

public Genomic getGenomic()
XXX

Specified by:
getGenomic in interface Taxon
Returns:
the Genomic for this Taxon System.
See Also:
Taxon.getGenomic()

getIdentifier

public java.lang.String getIdentifier()
Specified by:
getIdentifier in interface net.sf.tostring0.Identifiable
Overrides:
getIdentifier in class Evolvable_
Returns:
Evolvable_._identifier
See Also:
Evolvable_.getIdentifier()

getMortality

public Mortality getMortality()
Specified by:
getMortality in interface Taxon
Returns:
the application-specific implementer of Mortality.
See Also:
Taxon.getMortality()

getPhenome

public Phenome getPhenome()
XXX

Specified by:
getPhenome in interface Taxon
Returns:
value of (private) field _Phenome.
See Also:
Taxon.getPhenome()

getPhenotypeCache

public PhenotypeCache getPhenotypeCache()
Specified by:
getPhenotypeCache in interface HasPhenotypeCache
Returns:
the cache for phenotypes
See Also:
HasPhenotypeCache.getPhenotypeCache()

getPopulation

public Population getPopulation(int index)
TODO this method should be eliminated.

Parameters:
index -
Returns:
the indexth population among those which have organisms of this taxon.

getPopulations

public java.util.Collection<Population> getPopulations()
TODO this method should get the apporpriate populations from this taxon's Realm.

Returns:
a collection of populations which have organisms of this taxon.

getProperties

public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Bean method.

Returns:
the map of the arbitrary application-specific properties of this system.

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Method to get one of the arbitrary application-specific properties of this system.

Specified by:
getProperty in interface Taxon
Parameters:
key - the key to the property.
Returns:
the value of the property.
See Also:
Taxon.getProperty(java.lang.Object)

getRealm

public Realm getRealm()
Specified by:
getRealm in interface Taxon
Returns:
the realm to which this system belongs
See Also:
Taxon.getRealm()

getSeedPopulation

public int getSeedPopulation()
Specified by:
getSeedPopulation in interface Taxon
Returns:
seedPopulation

getVisualizableListeners

public java.util.Collection<VisualizableListener> getVisualizableListeners()
Description copied from interface: Taxon
Getter/setter typically called by reflection.

Specified by:
getVisualizableListeners in interface Taxon
Returns:
the population listeners as a collection.
See Also:
Taxon.getVisualizableListeners()

hashCode

public int hashCode()
Overrides:
hashCode in class Evolvable_
See Also:
Evolvable_.hashCode()

isFinished

public boolean isFinished()
First we check the super-method. If that determines that we are finished, then we return true; Otherwise, if any population is not finished we return false; Finally (if all populations are finished), we return true;

Specified by:
isFinished in interface Terminal
Overrides:
isFinished in class Evolvable_
Returns:
true if generation is >= to Evolvable_.maxGenerations. For a more complex condition, an evolvable could override this definition.
See Also:
Evolvable_.isFinished()

isLastGeneration

public boolean isLastGeneration()
TODO consider combining this with isFinished().

Specified by:
isLastGeneration in interface Taxon
Returns:
true if this is the last generation we will process
See Also:
Taxon.isLastGeneration()

nextGeneration

public boolean nextGeneration()
For each population in this system, call nextGeneration().

Specified by:
nextGeneration in interface Generational
Overrides:
nextGeneration in class Evolvable_
Returns:
true if all the populations in this system are healthy.
See Also:
Generational.nextGeneration()

registerBirths

public void registerBirths(Colony colony,
                           java.util.Collection<Organism> neonates)
Description copied from interface: Registry
TODO consider changing parameter to Colony

Specified by:
registerBirths in interface Registry
See Also:
Registry.registerBirths(Colony, java.util.Collection)

registerDeaths

public void registerDeaths(Colony colony,
                           java.util.Collection<Organism> deaths)
TEST

Specified by:
registerDeaths in interface Registry
See Also:
Registry.registerDeaths(Colony, java.util.Collection)

registerMarriages

public void registerMarriages(Colony colony,
                              java.util.Collection<Mating> marriages)
Specified by:
registerMarriages in interface Registry
See Also:
Registry.registerMarriages(Colony, java.util.Collection)

seedMembers

public void seedMembers()
For each population, call Theological.seedMembers(), passing value of organisms.

Specified by:
seedMembers in interface Theological
See Also:
Theological.seedMembers()

setPopulations

public void setPopulations(java.util.Collection<Population> populations)
This is the preferred way to set populations, rather than using the addPopulation(Population) method. Any previous populations are lost after invoking this method.

Specified by:
setPopulations in interface Taxon
Parameters:
populations - a Collection of Population objects.

setProperties

public void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Bean method.

Parameters:
properties - the map of the arbitrary application-specific properties of this system.

setProperty

public java.lang.Object setProperty(java.lang.String key,
                                    java.lang.Object value)
method to set one of the arbitrary application-specific properties of this system.

Specified by:
setProperty in interface Taxon
Parameters:
key -
value -
Returns:
the result of invoking Map.put(Object, Object).
See Also:
Taxon.setProperty(java.lang.String, java.lang.Object)

setRegistry

public void setRegistry(Registry registry)
Invoked via bean operations (e.g dependency injection)

Parameters:
registry -

setSeedPopulation

public void setSeedPopulation(int seedPopulation)
Parameters:
seedPopulation -

setVisualizableListeners

public void setVisualizableListeners(java.util.Collection<VisualizableListener> visualizableListeners)
This is called, but not addListener()

Specified by:
setVisualizableListeners in interface Taxon
See Also:
Taxon.setVisualizableListeners(java.util.Collection)


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.