Spring Data Core

org.springframework.data.geo
Class Distance

java.lang.Object
  extended by org.springframework.data.geo.Distance
All Implemented Interfaces:
Serializable

public class Distance
extends Object
implements Serializable

Value object to represent distances in a given metric.

Since:
1.8
Author:
Oliver Gierke, Thomas Darimont
See Also:
Serialized Form

Constructor Summary
Distance(double value)
          Creates a new Distance with a neutral metric.
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()
          Retruns the Metric of the Distance.
 double getNormalizedValue()
          Returns the normalized value regarding the underlying Metric.
 double getValue()
          Returns the distance value in the current Metric.
 int hashCode()
           
 Distance in(Metric metric)
          Returns a new Distance in the given Metric.
 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 with a neutral metric. This means the provided value needs to be in normalized form.

Parameters:
value -

Distance

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

Parameters:
value -
metric - can be null.
Method Detail

getValue

public double getValue()
Returns the distance value in the current Metric.

Returns:
the value

getNormalizedValue

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

Returns:

getMetric

public Metric getMetric()
Retruns the Metric of the Distance.

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 - must not be null.
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 - must not be null.
metric - must not be null.
Returns:

in

public Distance in(Metric metric)
Returns a new Distance in the given Metric. This means that the returned instance will have the same normalized value as the original instance.

Parameters:
metric - must not be null.
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 Core

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.