Bail out hard if we get negative steps from the database #91

We don't add them to the db for sure.
live-activity-data
cpfeiffer 2015-09-09 20:46:50 +02:00
parent 7f331a1bb1
commit e34c5614d7
1 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,19 @@ public class GBActivitySample implements ActivitySample {
this.intensity = intensity;
this.steps = steps;
this.type = type;
validate();
}
private void validate() {
if (steps < 0) {
throw new IllegalArgumentException("steps must be > 0");
}
if (intensity < 0) {
throw new IllegalArgumentException("intensity must be > 0");
}
if (timestamp < 0) {
throw new IllegalArgumentException("timestamp must be > 0");
}
}
@Override