Remove UnitConversions for time/durations.

This commit is contained in:
Dennis Guse
2022-07-01 16:22:07 +02:00
parent 45874d3749
commit 807ac3fc9f
8 changed files with 35 additions and 41 deletions
@@ -2,22 +2,35 @@ package de.dennisguse.opentracks.data.models;
import androidx.annotation.NonNull;
import java.time.Duration;
import java.util.Objects;
public class Cadence {
public static Cadence of(float value) {
return new Cadence(value);
public static Cadence of(float value, Duration duration) {
if (duration.isZero()) {
return zero();
}
return new Cadence(value / (duration.toMillis() / (float) Duration.ofMinutes(1).toMillis()));
}
private final float value;
public static Cadence of(float value_rpm) {
return new Cadence(value_rpm);
}
public static Cadence zero() {
return of(0.0f);
}
private final float value_rpm;
private Cadence(float value) {
this.value = value;
this.value_rpm = value;
}
public float getRPM() {
return value;
return value_rpm;
}
@Override
@@ -25,19 +38,19 @@ public class Cadence {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Cadence cadence = (Cadence) o;
return Float.compare(cadence.value, value) == 0;
return Float.compare(cadence.value_rpm, value_rpm) == 0;
}
@Override
public int hashCode() {
return Objects.hash(value);
return Objects.hash(value_rpm);
}
@NonNull
@Override
public String toString() {
return "Cadence{" +
"value=" + value + " rpm" +
"value=" + value_rpm + " rpm" +
'}';
}
}