com.rubecula.darwin.domain.helper
Interface Environment

All Superinterfaces:
CacheSignature, Censusible, java.lang.Cloneable, Countable, net.sf.tostring0.Identifiable, Visualizable
All Known Implementing Classes:
Environment_, Environment_Muirian, Environment_PepperedMoth, Environment_Susceptible, Environment_TS

public interface Environment
extends Visualizable, CacheSignature, java.lang.Cloneable

Defines the concept of an Environment, modeled as a map of EcoFactor objects. A Population of Organisms exist in an Environment, whose properties (the EcoFactor objects) can vary over time.

Author:
Robin Hillyard

Field Summary
static long IDEAL_POPULATION_DEFAULT
          100
static java.lang.String S_ID_UNIDENTIFIED
           
 
Method Summary
 java.lang.Object addFactor(EcoFactor factor)
          Add an eco factor to this environment.
 boolean addListener(EnvironmentListener listener)
          Mutating method to add a listener to changes in this Environment.
 java.util.Collection<java.lang.String> factorKeys()
           
 void fireEnvironmentChanged()
          Method to allow an external object to notify this Environment that it has changed, typically as the result of an external agent, for example a user action which has invoked update(String, Object).
 double getEcoFactorValue(java.lang.String name)
          Method to retrieve the value of the eco factor defined by name.
 java.util.Collection<EcoFactor> getEcoSystem()
           
 EcoFactor getFactor(java.lang.String name)
          Method to retrieve the eco factor defined by name.
 long getIdealPopulation()
           
 java.util.Collection<EnvironmentListener> getListeners()
           
 void init()
          Initialize this environment programatically (normally, initialization is done in the configuration).
 void setEcoSystem(java.util.Collection<EcoFactor> ecoFactors)
          Set the ecoFactors for this environment to the collection provided.
 void setIdealPopulation(long idealPopulation)
           
 void setListeners(java.util.Collection<EnvironmentListener> listeners)
          Reset the set of environment listeners according to the collection provided.
 boolean update(java.lang.String factorKey, java.lang.Object factorValue)
          Find and set the eco factor to have the factor value, then, if successful, invoke fireEnvironmentChanged().
 
Methods inherited from interface com.rubecula.darwin.foundation.Visualizable
getIndividuals, getRealm, getSink
 
Methods inherited from interface net.sf.tostring0.Identifiable
getIdentifier
 
Methods inherited from interface com.rubecula.darwin.foundation.Countable
getCount
 
Methods inherited from interface com.rubecula.darwin.domain.helper.Censusible
censusMe, getCensusibleChildren
 
Methods inherited from interface com.rubecula.darwin.domain.helper.CacheSignature
getSignature
 

Field Detail

IDEAL_POPULATION_DEFAULT

static final long IDEAL_POPULATION_DEFAULT
100

See Also:
Constant Field Values

S_ID_UNIDENTIFIED

static final java.lang.String S_ID_UNIDENTIFIED
See Also:
Constant Field Values
Method Detail

addFactor

java.lang.Object addFactor(EcoFactor factor)
Add an eco factor to this environment. This is not the favored method to add eco factors to an environment. Normally, we would do them all at once using setEcoSystem(Collection).

Parameters:
factor - the eco factor, whose identifier will be used as the key.
Returns:
the previous eco factor with the same identifier (if any), otherwise null.

addListener

boolean addListener(EnvironmentListener listener)
Mutating method to add a listener to changes in this Environment.

Parameters:
listener - the listener.
Returns:
true if the listener was successfully added.

factorKeys

java.util.Collection<java.lang.String> factorKeys()
Returns:
the set of eco factor identifiers

fireEnvironmentChanged

void fireEnvironmentChanged()
Method to allow an external object to notify this Environment that it has changed, typically as the result of an external agent, for example a user action which has invoked update(String, Object).


getEcoFactorValue

double getEcoFactorValue(java.lang.String name)
Method to retrieve the value of the eco factor defined by name.

Parameters:
name - the name (identifier, key) of the eco factor.
Returns:
the eco factor value, as a double. If the value cannot be rendered as double, the result is undefined. XXX consider eliminating this method.

getEcoSystem

java.util.Collection<EcoFactor> getEcoSystem()
Returns:
the set of EcoFactors which makes up this environment

getFactor

EcoFactor getFactor(java.lang.String name)
Method to retrieve the eco factor defined by name.

Parameters:
name - the name (identifier, key) of the eco factor.
Returns:
the eco factor value itself.

getIdealPopulation

long getIdealPopulation()
Returns:
the ideal population

getListeners

java.util.Collection<EnvironmentListener> getListeners()
Returns:
the current set of environment listeners. Getter/Setter typically called by reflection.

init

void init()
Initialize this environment programatically (normally, initialization is done in the configuration).


setEcoSystem

void setEcoSystem(java.util.Collection<EcoFactor> ecoFactors)
Set the ecoFactors for this environment to the collection provided. Any prior ecoFactors are forgotten.

Parameters:
ecoFactors -

setIdealPopulation

void setIdealPopulation(long idealPopulation)
Parameters:
idealPopulation -

setListeners

void setListeners(java.util.Collection<EnvironmentListener> listeners)
Reset the set of environment listeners according to the collection provided. Any prior listeners will be lost.

Parameters:
listeners - Getter/Setter typically called by reflection.

update

boolean update(java.lang.String factorKey,
               java.lang.Object factorValue)
Find and set the eco factor to have the factor value, then, if successful, invoke fireEnvironmentChanged().

Parameters:
factorKey -
factorValue -
Returns:
true if the environment was updated.


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