MCPcopy Create free account
hub / github.com/apache/sirona / convert

Method convert

api/src/main/java/org/apache/sirona/counters/Unit.java:153–161  ·  view source on GitHub ↗

Convert value from unit to this unit (if conpatible) @param value value to convert @param unit unit of value @return value converted to this unit

(final double value, final Unit unit)

Source from the content-addressed store, hash-verified

151 * @return value converted to this unit
152 */
153 public double convert(final double value, final Unit unit) {
154 if (unit == this) {
155 return value;
156 }
157 if (!isCompatible(unit)) {
158 throw new IllegalArgumentException("unit " + name + " is incompatible with unit " + unit.name);
159 }
160 return value * unit.getScale() / scale;
161 }
162
163 public boolean isPrimary() {
164 return primary == this;

Callers 3

allMethod · 0.95
addMethod · 0.45
addMethod · 0.45

Calls 2

isCompatibleMethod · 0.95
getScaleMethod · 0.80

Tested by

no test coverage detected