Package yearreview.app.util.value
Class DurationValue
java.lang.Object
yearreview.app.util.value.Value
yearreview.app.util.value.DurationValue
- All Implemented Interfaces:
Comparable<Value>
- Author:
- ColdStone37
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Duration
Duration stored in this object.private static final int
Parts of the Duration to output in thetoString()
-function.private static final String[]
Abbreviations of the intervals.private static final long[]
Amount of values in each Interval (e.g.private static final int[]
Maximum amount of spaces needed for Values in each interval (equivalent to floor(log10(INTERVAL_SIZES))). -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Compares to another Value-object.getType()
Gets the Type of this Value.protected Object
getValue()
Gets the internally used Value to measure the duration.Gets a DurationValue that has to sum of this object and the other-object.toString()
Formats the Duration to a String.
-
Field Details
-
DURATION_SHOW_PARTS
private static final int DURATION_SHOW_PARTSParts of the Duration to output in thetoString()
-function.- See Also:
-
INTERVAL_SIZES
private static final long[] INTERVAL_SIZESAmount of values in each Interval (e.g. 1000ms = 1s; 60s = 1min; ...). -
INTERVAL_VALUE_LENGTHS
private static final int[] INTERVAL_VALUE_LENGTHSMaximum amount of spaces needed for Values in each interval (equivalent to floor(log10(INTERVAL_SIZES))). -
INTERVAL_NAMES
Abbreviations of the intervals. -
duration
Duration stored in this object.
-
-
Constructor Details
-
DurationValue
Constructs a new DurationValue from a Duration- Parameters:
d
- duration
-
-
Method Details
-
getType
Gets the Type of this Value.- Specified by:
getType
in classValue
- Returns:
ValueType.DURATION
-
toString
Formats the Duration to a String. -
plus
Gets a DurationValue that has to sum of this object and the other-object. -
getValue
Gets the internally used Value to measure the duration. -
compareTo
Compares to another Value-object.- Parameters:
other
- Value-object to compare against- Returns:
- comparison of durations or
Integer.MAX_VALUE
if the other Value isn't a DurationValue
-