public final class Distance extends Object implements Serializable, Comparable<Distance>
Constructor and Description |
---|
Distance(double value)
Creates a new
Distance with a neutral metric. |
Distance(double value,
Metric metric)
|
Modifier and Type | Method and Description |
---|---|
Distance |
add(Distance other)
Adds the given distance to the current one.
|
Distance |
add(Distance other,
Metric metric)
|
static Range<Distance> |
between(Distance min,
Distance max)
|
static Range<Distance> |
between(double minValue,
Metric minMetric,
double maxValue,
Metric maxMetric)
|
int |
compareTo(Distance that) |
boolean |
equals(Object o) |
Metric |
getMetric()
|
double |
getNormalizedValue()
Returns the normalized value regarding the underlying
Metric . |
String |
getUnit()
Returns a
String representation of the unit the distance is in. |
double |
getValue()
The distance value in the current
Metric . |
int |
hashCode() |
Distance |
in(Metric metric)
|
String |
toString() |
public Distance(double value)
Distance
with a neutral metric. This means the provided value needs to be in normalized form.value
- public Distance(double value, Metric metric)
value
- metric
- must not be null.public static Range<Distance> between(Distance min, Distance max)
min
- can be null.max
- can be null.public static Range<Distance> between(double minValue, Metric minMetric, double maxValue, Metric maxMetric)
minValue
- minMetric
- can be null.maxValue
- maxMetric
- can be null.public double getNormalizedValue()
Metric
.public String getUnit()
String
representation of the unit the distance is in.Metric.getAbbreviation()
public Distance add(Distance other)
Distance
will be in the same metric as the
current one.other
- must not be null.public Distance add(Distance other, Metric metric)
other
- must not be null.metric
- must not be null.public Distance in(Metric metric)
Distance
in the given Metric
. This means that the returned instance will have the
same normalized value as the original instance.metric
- must not be null.public int compareTo(@Nullable Distance that)
compareTo
in interface Comparable<Distance>
public double getValue()
Metric
.public Metric getMetric()
Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.