dk.deepthought.sidious.greenhouse
Class ClimaticState

java.lang.Object
  extended by dk.deepthought.sidious.greenhouse.ClimaticState
All Implemented Interfaces:
State

@Immutable
public class ClimaticState
extends java.lang.Object
implements State

This class represents a climatic state of the environment. It is a collection of environmental sensor inputs.

Author:
Deepthought

Field Summary
private static org.apache.commons.logging.Log logger
          Logger for this class.
(package private) static java.util.Comparator<SensorInput> SENSOR_ORDER
          This comparator orders sensors by their SuperLinkID.
private  java.util.List<SensorInput> sensors
          The list of sensors.
 
Constructor Summary
ClimaticState(java.util.Collection<SensorInput> sensors)
          Creates a ClimaticState object containing the specified sensor inputs.
 
Method Summary
(package private) static ClimaticState average(java.util.Collection<ClimaticState> states)
          Calculates and returns the average State, based on the input states.
 boolean equals(java.lang.Object obj)
           
 java.util.Collection<SensorInput> getSensors()
          Gets a Collection of SensorInput
 int hashCode()
           
 State impact(java.util.Collection<State> states)
          Calculates and returns the collective impact of applying the input states to the current environment.
private  ClimaticState incrementTime()
          Increments the time of this.
 boolean partiallyEquals(State state)
          Checks whether this state contains all state descriptors of the input state.
 boolean sameStateSpace(State other)
          Verifies if the specified state belongs to the same state space as this.
(package private)  ClimaticState sum(ClimaticState other)
          This method calculates the sum of this ClimaticState and other.
(package private) static java.util.ArrayList<ClimaticState> toClimaticStateList(java.util.Collection<State> states)
          This method converts the input State objects to a list of ClimaticState objects.
 java.lang.String toString()
           
(package private) static ClimaticState total(java.util.ArrayList<ClimaticState> states, ClimaticState total)
          This method calculates the total sum of all related sensor inputs in the states.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final org.apache.commons.logging.Log logger
Logger for this class.


sensors

private final java.util.List<SensorInput> sensors
The list of sensors.


SENSOR_ORDER

static final java.util.Comparator<SensorInput> SENSOR_ORDER
This comparator orders sensors by their SuperLinkID.

Constructor Detail

ClimaticState

public ClimaticState(java.util.Collection<SensorInput> sensors)
Creates a ClimaticState object containing the specified sensor inputs.

Parameters:
sensors - a collection of sensor inputs related this climatic state
Method Detail

impact

public State impact(java.util.Collection<State> states)
Description copied from interface: State
Calculates and returns the collective impact of applying the input states to the current environment.

Specified by:
impact in interface State
Parameters:
states - the input states
Returns:
the resulting state

average

static ClimaticState average(java.util.Collection<ClimaticState> states)
Calculates and returns the average State, based on the input states.

The method returns null, when presented with null or an empty collection.

Parameters:
states - states to base calculation on
Returns:
the average state

toClimaticStateList

static java.util.ArrayList<ClimaticState> toClimaticStateList(java.util.Collection<State> states)
This method converts the input State objects to a list of ClimaticState objects.

Parameters:
states - input states to be concerted
Returns:
the input states as climatic states

total

static ClimaticState total(java.util.ArrayList<ClimaticState> states,
                           ClimaticState total)
This method calculates the total sum of all related sensor inputs in the states. The sum is calculated recursively.

The method returns null, when presented with null or an empty collection.

Parameters:
states - the list of climatic states to be summed
total - the parameter in which the sum will be calculated; is needed for recursive purposes
Returns:
a ClimaticState representing the total sum of the related sensor inputs

sum

ClimaticState sum(ClimaticState other)
This method calculates the sum of this ClimaticState and other.

The method returns a deep-copy of this, when presented with null.

Parameters:
other - the other climatic state

sameStateSpace

public boolean sameStateSpace(State other)
Description copied from interface: State
Verifies if the specified state belongs to the same state space as this.

Returns true if this state and other are in the same state space, false otherwise.

Specified by:
sameStateSpace in interface State
Parameters:
other - the other state
Returns:
true if in same state space, false otherwise.

partiallyEquals

public boolean partiallyEquals(State state)
Description copied from interface: State
Checks whether this state contains all state descriptors of the input state.

Specified by:
partiallyEquals in interface State
Parameters:
state - input state
Returns:
true if all state descriptors are included

getSensors

public java.util.Collection<SensorInput> getSensors()
Gets a Collection of SensorInput

Returns:
the sensors related to this climatic state

incrementTime

private ClimaticState incrementTime()
Increments the time of this.

Returns:
the time incremented version of this.

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © Deepthought Development - All Rights Reserved.