Cleanup: SensorDataCyclingDistanceSpeed.Data is a record.

This commit is contained in:
Dennis Guse
2023-11-15 07:20:03 +01:00
parent 58d79380cf
commit d47fa27e02
4 changed files with 7 additions and 44 deletions
@@ -73,38 +73,5 @@ public class SensorDataCyclingDistanceSpeed extends SensorData<BluetoothHandlerC
this.wheelCircumference = wheelCircumference;
}
// TODO Make record
public static class Data {
private final Distance distance;
private final Distance distanceOverall;
private final Speed speed;
private Data(Distance distance, Distance distanceOverall, Speed speed) {
this.distance = distance;
this.distanceOverall = distanceOverall;
this.speed = speed;
}
public Distance getDistance() {
return distance;
}
public Distance getDistanceOverall() {
return distanceOverall;
}
public Speed getSpeed() {
return speed;
}
@NonNull
@Override
public String toString() {
return "Data{" +
"distance=" + getDistance() +
", distance_overall=" + getDistanceOverall() +
", speed=" + getSpeed() +
'}';
}
}
public record Data(Distance distance, Distance distanceOverall, Speed speed) {}
}
@@ -68,8 +68,8 @@ public final class SensorDataSet {
}
public Pair<Speed, String> getSpeed() {
if (cyclingDistanceSpeed != null && cyclingDistanceSpeed.hasValue() && cyclingDistanceSpeed.getValue().getSpeed() != null) {
return new Pair<>(cyclingDistanceSpeed.getValue().getSpeed(), cyclingDistanceSpeed.getSensorNameOrAddress());
if (cyclingDistanceSpeed != null && cyclingDistanceSpeed.hasValue() && cyclingDistanceSpeed.getValue().speed() != null) {
return new Pair<>(cyclingDistanceSpeed.getValue().speed(), cyclingDistanceSpeed.getSensorNameOrAddress());
}
if (runningDistanceSpeedCadence != null && runningDistanceSpeedCadence.hasValue() && runningDistanceSpeedCadence.getValue().speed() != null) {
@@ -143,7 +143,7 @@ public final class SensorDataSet {
}
if (cyclingDistanceSpeed != null && cyclingDistanceSpeed.hasValue()) {
trackPoint.setSensorDistance(cyclingDistanceSpeed.getValue().getDistanceOverall());
trackPoint.setSensorDistance(cyclingDistanceSpeed.getValue().distanceOverall());
}
if (cyclingPower != null && cyclingPower.hasValue()) {