Predictions 4.10.0.0

hirondelle.predict.main.prediction
Class Prediction

Object
  extended by hirondelle.predict.main.prediction.Prediction

public final class Prediction
extends Object

Model Object for a Prediction.

This class is interesting since it does not include the foreign key to the PredictionList table; that is taken only from the session, not from the database, nor from user input.

This object is immutable, and makes defensive copies where needed.


Constructor Summary
Prediction(Id aId, Id aParentId, SafeText aText, DateTime aCreationDate, SafeText aRemark, Id aOutcome, DateTime aOutcomeDate)
          Full constructor.
Prediction(Id aId, Id aParentId, SafeText aText, SafeText aRemark, Id aOutcome)
          Partial constructor, used for user input.
 
Method Summary
static Integer calculateAverageScore(List<Prediction> aPredictions)
          Calculate the average of getOutcomeScore() for all of the predictions in a list.
 boolean equals(Object aThat)
           
 DateTime getCreationDate()
           
 Id getId()
           
 Code getOutcome()
           
 DateTime getOutcomeDate()
           
 Integer getOutcomeScore()
          Returns null if there is no outcome.
 Id getParentId()
           
 SafeText getRemark()
           
 SafeText getText()
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Prediction

public Prediction(Id aId,
                  Id aParentId,
                  SafeText aText,
                  DateTime aCreationDate,
                  SafeText aRemark,
                  Id aOutcome,
                  DateTime aOutcomeDate)
           throws ModelCtorException
Full constructor. Used when fetching from the database.

Parameters:
aId - internal database identifier (optional)
aParentId - internal database identifier (required)
aText - main text of the prediction max 255 characters (required)
aCreationDate - date-time the prediction was created (required)
aRemark - any remark the user may wish to make (justification, special remark on the outcome, etc.) max 2000 chars (optional)
aOutcome - final outcome of the prediction (optional)
aOutcomeDate - Date the final outcome was established, if ever (optional); if outcome is specified, then the outcome date must also be specified
Throws:
ModelCtorException

Prediction

public Prediction(Id aId,
                  Id aParentId,
                  SafeText aText,
                  SafeText aRemark,
                  Id aOutcome)
           throws ModelCtorException
Partial constructor, used for user input.

Similar to the full constructor, but the user never inputs the creation date, or the outcome date. Here, those dates are simply set to null.

Throws:
ModelCtorException
Method Detail

getId

public Id getId()

getParentId

public Id getParentId()

getText

public SafeText getText()

getCreationDate

public DateTime getCreationDate()

getRemark

public SafeText getRemark()

getOutcome

public Code getOutcome()

getOutcomeScore

public Integer getOutcomeScore()
Returns null if there is no outcome. Otherwise, returns the score attached to the outcome (see CodeTable.OUTCOMES).


getOutcomeDate

public DateTime getOutcomeDate()

calculateAverageScore

public static Integer calculateAverageScore(List<Prediction> aPredictions)
Calculate the average of getOutcomeScore() for all of the predictions in a list.

Predictions which have a null outcome do not contribute to the result. If none of the predictions in the list have an outcome, then null is returned. Integer division is used to calculate the result, so there will be some rounding.


toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object aThat)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Predictions 4.10.0.0

Copyright Hirondelle Systems - Generated 2013Oct19.12.27