Package yearreview.app.util.value
Class DistanceValue
java.lang.Object
yearreview.app.util.value.Value
yearreview.app.util.value.DistanceValue
- All Implemented Interfaces:
 Comparable<Value>
A 
Value that represents a Distance, internally using the Length-Datatype.- Author:
 - ColdStone37
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final io.jenetics.jpx.LengthInternal representation of the Distance.private static final intPrecision to use in thetoString()-function.Mapping from all units to their abbreviations. - 
Constructor Summary
ConstructorsConstructorDescriptionDistanceValue(double distance, io.jenetics.jpx.Length.Unit unit) Constructs a DistanceValue from a distance in a certain unit.DistanceValue(io.jenetics.jpx.Length distance) Constructs a DistanceValue from aLength. - 
Method Summary
Modifier and TypeMethodDescriptionintCompares to another Value-object.getType()Gets the Type of this Value.protected ObjectgetValue()Gets the internally used Value to measure the distance.Gets a DistanceValue that has to sum of this object and the other-object.toString()Formats the Distance to a String.toString(io.jenetics.jpx.Length.Unit unit) Formats the Distance to a String in a certain unit. 
- 
Field Details
- 
DISTANCE_PRECISION
private static final int DISTANCE_PRECISIONPrecision to use in thetoString()-function.- See Also:
 
 - 
distance
private final io.jenetics.jpx.Length distanceInternal representation of the Distance. - 
lengthUnitShort
Mapping from all units to their abbreviations. 
 - 
 - 
Constructor Details
- 
DistanceValue
public DistanceValue(io.jenetics.jpx.Length distance) Constructs a DistanceValue from aLength.- Parameters:
 distance- distance to initialize the DistanceValue with
 - 
DistanceValue
public DistanceValue(double distance, io.jenetics.jpx.Length.Unit unit) Constructs a DistanceValue from a distance in a certain unit.- Parameters:
 distance- distance to initialize the DistanceValue withunit- unit of the value in the distance argument
 
 - 
 - 
Method Details
- 
getType
Gets the Type of this Value.- Specified by:
 getTypein classValue- Returns:
 ValueType.DISTANCE
 - 
toString
Formats the Distance to a String. - 
toString
Formats the Distance to a String in a certain unit.- Parameters:
 unit- unit to format the distance to- Returns:
 - formatted distance (e.g. 123.45 ft)
 
 - 
plus
Gets a DistanceValue that has to sum of this object and the other-object. - 
getValue
Gets the internally used Value to measure the distance. - 
compareTo
Compares to another Value-object.- Parameters:
 other- Value-object to compare against- Returns:
 - comparison of distances or 
Integer.MAX_VALUEif the other Value isn't a DistanceValue 
 
 -