MCPcopy Create free account
hub / github.com/MenoData/Time4J / AbstractMetric

Class AbstractMetric

base/src/main/java/net/time4j/engine/AbstractMetric.java:75–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 * @see AbstractDuration
74 */
75public abstract class AbstractMetric<U extends ChronoUnit, P extends AbstractDuration<U>>
76 implements TimeMetric<U, P>, Comparator<U> {
77
78 //~ Statische Felder/Initialisierungen --------------------------------
79
80 private static final int MIO = 1000000;
81 private static final double LENGTH_OF_FORTNIGHT = 86400.0 * 14;
82
83 //~ Instanzvariablen --------------------------------------------------
84
85 private final List<U> sortedUnits;
86 private final boolean normalizing;
87
88 //~ Konstruktoren -----------------------------------------------------
89
90 /**
91 * <p>Creates a new default metric with given array of time units. </p>
92 *
93 * <p>The given time units can be in any arbitrary order, but internally
94 * the will be automatically sorted by their default estimated length. </p>
95 *
96 * @param normalizing Is normalizing required that is shall amounts
97 * in small units be converted to bigger units?
98 * @param units time units to be used for calculating time span
99 * @throws IllegalArgumentException if any time unit is given more than
100 * once or if there is no time unit at all
101 */
102 /*[deutsch]
103 * <p>Konstruiert eine neue Standardmetrik mit einem Array von
104 * Zeiteinheiten. </p>
105 *
106 * <p>Die Zeiteinheiten k&ouml;nnen in beliebiger Reihenfolge
107 * angegeben werden, aber intern werden sie &uuml;ber ihre
108 * Standardl&auml;nge automatisch sortiert. </p>
109 *
110 * @param normalizing Is normalizing required that is shall amounts
111 * in small units be converted to bigger units?
112 * @param units time units to be used for calculating time span
113 * @throws IllegalArgumentException if any time unit is given more than
114 * once or if there is no time unit at all
115 */
116 @SafeVarargs
117 protected AbstractMetric(
118 boolean normalizing,
119 U... units
120 ) {
121 this(Arrays.asList(units), normalizing);
122 }
123
124 /**
125 * <p>Creates a new default metric with given collection of time units. </p>
126 *
127 * <p>The given time units can be in any arbitrary order, but internally
128 * the will be automatically sorted by their default estimated length. </p>
129 *
130 * @param normalizing Is normalizing required that is shall amounts
131 * in small units be converted to bigger units?
132 * @param units time units to be used for calculating time span

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected