Class Distance
java.lang.Object
org.springframework.data.geo.Distance
- All Implemented Interfaces:
Serializable
,Comparable<Distance>
Value object to represent distances in a given metric.
- Since:
- 1.8
- Author:
- Oliver Gierke, Thomas Darimont
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the given distance to the current one.int
boolean
double
Returns the normalized value regarding the underlyingMetric
.getUnit()
Returns aString
representation of the unit the distance is in.double
getValue()
int
hashCode()
static Distance
of
(double value) Creates a newDistance
with a neutral metric.static Distance
toString()
-
Constructor Details
-
Distance
public Distance(double value) Creates a newDistance
with a neutral metric. This means the provided value needs to be in normalized form.- Parameters:
value
- distance value.
-
Distance
-
-
Method Details
-
of
-
of
-
between
-
between
-
getNormalizedValue
public double getNormalizedValue()Returns the normalized value regarding the underlyingMetric
.- Returns:
- the normalized value.
-
getUnit
-
add
Adds the given distance to the current one. The resultingDistance
will be in the same metric as the current one.- Parameters:
other
- must not be null.- Returns:
- sum of this and the other distance.
-
add
-
in
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Distance>
-
getValue
public double getValue() -
getMetric
-
equals
-
hashCode
-
toString
-