Spring Data Document

org.springframework.data.mongodb.core.geo
Class Distance

java.lang.Object
  extended by org.springframework.data.mongodb.core.geo.Distance

public class Distance
extends Object

Value object to represent distances in a given metric.

Author:
Oliver Gierke

Constructor Summary
Distance(double value)
          Creates a new Distance.
Distance(double value, Metric metric)
          Creates a new Distance with the given Metric.
 
Method Summary
 Distance add(Distance other)
          Adds the given distance to the current one.
 Distance add(Distance other, Metric metric)
          Adds the given Distance to the current one and forces the result to be in a given Metric.
 boolean equals(Object obj)
           
 Metric getMetric()
           
 double getNormalizedValue()
          Returns the normalized value regarding the underlying Metric.
 double getValue()
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Distance

public Distance(double value)
Creates a new Distance.

Parameters:
value -

Distance

public Distance(double value,
                Metric metric)
Creates a new Distance with the given Metric.

Parameters:
value -
metric -
Method Detail

getValue

public double getValue()
Returns:
the value

getNormalizedValue

public double getNormalizedValue()
Returns the normalized value regarding the underlying Metric.

Returns:

getMetric

public Metric getMetric()
Returns:
the metric

add

public Distance add(Distance other)
Adds the given distance to the current one. The resulting Distance will be in the same metric as the current one.

Parameters:
other -
Returns:

add

public Distance add(Distance other,
                    Metric metric)
Adds the given Distance to the current one and forces the result to be in a given Metric.

Parameters:
other -
metric -
Returns:

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

Spring Data Document

Copyright © 2012. All Rights Reserved.