Package org.springframework.data.geo
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
- Parameters:
value
-metric
- must not be null.
-
-
Method Details
-
of
Creates a newDistance
with a neutral metric. This means the provided value needs to be in normalized form.- Parameters:
value
- distance value.- Since:
- 4.0
-
of
- Parameters:
value
- distance value.metric
- must not be null.- Since:
- 4.0
-
between
- Parameters:
min
- can be null.max
- can be null.- Returns:
- will never be null.
-
between
public static Range<Distance> between(double minValue, Metric minMetric, double maxValue, Metric maxMetric) - Parameters:
minValue
- minimum value.minMetric
- can be null.maxValue
- maximum value.maxMetric
- can be null.- Returns:
- the
Range
between the given values.
-
getNormalizedValue
public double getNormalizedValue()Returns the normalized value regarding the underlyingMetric
.- Returns:
- the normalized value.
-
getUnit
Returns aString
representation of the unit the distance is in.- Returns:
- the unit
- See Also:
-
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
- Parameters:
other
- must not be null.metric
- must not be null.- Returns:
- sum of this and the other distance.
-
in
Returns a newDistance
in the givenMetric
. This means that the returned instance will have the same normalized value as the original instance.- Parameters:
metric
- must not be null.- Returns:
- the converted
Distance
.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Distance>
-
getValue
public double getValue() -
getMetric
-
equals
-
hashCode
public int hashCode() -
toString
-