U - generic type of time unit (ChronoUnit)public abstract class AbstractMetric<U extends ChronoUnit,P extends AbstractDuration<U>> extends Object implements TimeMetric<U,P>, Comparator<U>
Represents a metric suitable for the default algorithm of Time4J.
If the starting time point is after the end time point then a
duration computed with this metric will be negative. In this case
the metric defined here will first toggle the time points to be
compared and then compare all elements in the order of ascending
precision. Elements which differ less than a full unit will cause
an amount of 0 in related duration item. Convertible units
will be consolidated in one step. Finally the representation of
the duration will be normalized such that small units will be
converted to larger units if possible.
AbstractDuration| Constructor and Description |
|---|
AbstractMetric(boolean normalizing,
Set<U> units)
Creates a new default metric with given set of time units.
|
AbstractMetric(boolean normalizing,
U... units)
Creates a new default metric with given array of time units.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends TimePoint<? super U,T>> |
between(T start,
T end)
Computes the temporal distance between two time points.
|
int |
compare(U u1,
U u2)
Compares time units by their length in descending order.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequalspublic AbstractMetric(boolean normalizing,
U... units)
Creates a new default metric with given array of time units.
The given time units can be in any arbitrary order, but internally the will be automatically sorted by their default estimated length.
normalizing - Is normalizing required that is shall amounts
in small units be converted to bigger units?units - time units to be used for calculating time spanIllegalArgumentException - if any time unit is given more than
once or if there is no time unit at allpublic AbstractMetric(boolean normalizing,
Set<U> units)
Creates a new default metric with given set of time units.
The given time units can be in any arbitrary order, but internally the will be automatically sorted by their default estimated length.
normalizing - Is normalizing required that is shall amounts
in small units be converted to bigger units?units - time units to be used for calculating time spanIllegalArgumentException - if there is not time unit at allpublic int compare(U u1, U u2)
Compares time units by their length in descending order.
compare in interface Comparator<U extends ChronoUnit>u1 - first time unitu2 - second time unitpublic <T extends TimePoint<? super U,T>> P between(T start, T end)
TimeMetricComputes the temporal distance between two time points.
between in interface TimeMetric<U extends ChronoUnit,P extends AbstractDuration<U>>T - generic type of time pointstart - first time pointend - second time pointstart is after endCopyright © 2014. All rights reserved.