public class Assessment extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, java.lang.Comparable<Assessment>
Modifier and Type | Field and Description |
---|---|
static java.text.NumberFormat |
PERCENT_FORMAT
Percent format with minimum and maximum fraction digit of 1
|
Constructor and Description |
---|
Assessment()
Creates an empty assessment (i.e.
|
Assessment(ETrafficLightColor color)
Create an assessment with a single color entry.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Assessment a)
Adds the
Assessment by merging the provided assessment into this,
i.e. |
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 based on sum of assessment values.
|
int |
compareTo(Assessment other)
Compares assessment values lexicographically, i.e.
|
int |
compareToRelative(Assessment other)
Compares both assessments by the percentage of their dominant colors.
|
boolean |
equals(java.lang.Object obj) |
int |
getColorFrequency(ETrafficLightColor color) |
ETrafficLightColor |
getDominantColor()
Returns the first color of the
ETrafficLightColor enumeration for
which this assessment has a positive count. |
ETrafficLightColor |
getMostFrequentColor() |
int |
getSize()
Returns the size of the assessment, i.e.
|
int |
hashCode() |
void |
subtract(Assessment a)
Subtracts the provided assessment from this one, i.e.
|
java.lang.String |
toFormattedColors()
Return a formatted string of all traffic light colors with absolute and
relative values greater 0.
|
java.lang.String |
toString() |
public static final java.text.NumberFormat PERCENT_FORMAT
public Assessment()
public Assessment(ETrafficLightColor color)
color
- the color included in this assessment.public int getSize()
public final void add(ETrafficLightColor color)
color
- the color added to this assessment.public final void add(ETrafficLightColor color, int count)
color
- the color added to this assessment.count
- how often to add this color to the assessment.public final void add(Assessment a)
Assessment
by merging the provided assessment into this,
i.e. increase all traffic light color counts by the values in the provided
assessment.a
- the assessment to merge in.public final void subtract(Assessment a)
a
- the assessment to merge in.public int getColorFrequency(ETrafficLightColor color)
color
- the color whose frequency to read.public ETrafficLightColor getDominantColor()
ETrafficLightColor
enumeration for
which this assessment has a positive count. The enumeration is ordered in a
way, that more dominant colors are on top. For example the dominant color is
red, if at least one red value is in the assessment.public ETrafficLightColor getMostFrequentColor()
getDominantColor()
) one is returned.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toFormattedColors()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(Assessment other)
compareTo
in interface java.lang.Comparable<Assessment>
public int compareToRelative(Assessment other)
public static Assessment aggregate(java.util.Collection<Assessment> values)