TUM CCSM Commons

edu.tum.cs.commons.assessment
Class Assessment

java.lang.Object
  extended by edu.tum.cs.commons.assessment.Assessment
All Implemented Interfaces:
IDeepCloneable, java.io.Serializable, java.lang.Cloneable

public class Assessment
extends java.lang.Object
implements java.lang.Cloneable, IDeepCloneable, java.io.Serializable

This class stores an assessment. An assessment is a multiset of traffic light colors (i.e. a mapping from traffic light colors to non-negative integers).

Version:
$Rev: 27816 $
Author:
Benjamin Hummel, $Author: hummelb $
See Also:
Serialized Form
Rating:
GREEN Hash: E1A8D09889F5CFB5BAD863BEB224644F

Constructor Summary
Assessment()
          Creates an empty assessment (i.e. one with all entries set to 0).
Assessment(ETrafficLightColor color)
          Create an assessment with a single color entry.
Assessment(ETrafficLightColor color, java.lang.String message)
          Create an assessement with a assessment message.
 
Method Summary
 void add(Assessment a)
          Merge the provided assessment into this, i.e. increase all trafic light color counts by the values in the provided asseessment.
 void add(ETrafficLightColor color)
          Add a single entry of this color to this assessment.
 void add(ETrafficLightColor color, int count)
          Add a single entry of this color to this assessment.
static Assessment aggregate(java.util.Collection<Assessment> values)
          Aggregate assessments.
protected  java.lang.Object clone()
          
 Assessment deepClone()
          Deep clone of this object.
 boolean equals(java.lang.Object obj)
          
 int getColorFrequency(ETrafficLightColor color)
           
 ETrafficLightColor getDominantColor()
           
 java.lang.String getMessage()
          Get assessment message.
 ETrafficLightColor getMostFrequentColor()
           
 int hashCode()
          
 void setMessage(java.lang.String message)
          Set assessment message.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Assessment

public Assessment()
Creates an empty assessment (i.e. one with all entries set to 0).


Assessment

public Assessment(ETrafficLightColor color)
Create an assessment with a single color entry.

Parameters:
color - the color included in this assessment.

Assessment

public Assessment(ETrafficLightColor color,
                  java.lang.String message)
Create an assessement with a assessment message.

Method Detail

add

public void add(ETrafficLightColor color)
Add a single entry of this color to this assessment.

Parameters:
color - the color added to this assessment.

add

public void add(ETrafficLightColor color,
                int count)
Add a single entry of this color to this assessment.

Parameters:
color - the color added to this assessment.
count - how often to add this color to the assessment.

add

public void add(Assessment a)
Merge the provided assessment into this, i.e. increase all trafic light color counts by the values in the provided asseessment.

Parameters:
a - the assessment to merge in.

getColorFrequency

public int getColorFrequency(ETrafficLightColor color)
Parameters:
color - the color whose frequency to read.
Returns:
the number of occurrences of the provided color in this assessment.

getDominantColor

public ETrafficLightColor getDominantColor()
Returns:
the most dominant color. If there is a RED entry, RED is returned. Otherwise, if there is a YELLOW entry, YELLOW is returned. If there is neither a RED OR YELLOW entry, but a GREEN one, GREEN is returned. If no color is there, UNKNOWN is returned. This method relies on the fact that the entries in ETrafficLightColor are ordered according to their dominance.

getMostFrequentColor

public ETrafficLightColor getMostFrequentColor()
Returns:
the color that is most frequent in this assessment. If all frequencies are 0, UNKNOWN is returned. If there are ties, the more dominant (see getDominantColor()) one is returned.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

deepClone

public Assessment deepClone()
Deep clone of this object.

Specified by:
deepClone in interface IDeepCloneable

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

getMessage

public java.lang.String getMessage()
Get assessment message.

Returns:
the message or null if this assessment has no message.

setMessage

public void setMessage(java.lang.String message)
Set assessment message.

Parameters:
message - the message or null if this assessment has no message.

aggregate

public static Assessment aggregate(java.util.Collection<Assessment> values)
Aggregate assessments.


TUM CCSM Commons

TUM CCSM Commons - 2.7