This repository has been archived by the owner on Feb 27, 2021. It is now read-only.
/
DailyStats.java
50 lines (44 loc) · 1.62 KB
/
DailyStats.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package endafarrell.orla.service.data;
import endafarrell.orla.service.OrlaDateTimeFormat;
import endafarrell.orla.service.OrlaObject;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.JsonNodeFactory;
import org.codehaus.jackson.node.ObjectNode;
import org.joda.time.DateTime;
public class DailyStats implements OrlaObject {
final DateTime dateTime;
final int numReadings;
final double simpleMean;
final double timeWeightedMean;
final double ascDesc;
final ObjectNode json;
public DailyStats(final DateTime dateTime,
final int numReadings,
final double simpleMean,
final double timeWeightedMean,
final double ascDesc) {
this.dateTime = dateTime.withTimeAtStartOfDay();
this.numReadings = numReadings;
this.simpleMean = simpleMean;
this.timeWeightedMean = timeWeightedMean;
this.ascDesc = ascDesc;
this.json = JsonNodeFactory.instance.objectNode();
json.put("date", OrlaDateTimeFormat.PRETTY_yyyyMMdd.print(dateTime));
json.put("numReadings", numReadings);
json.put("meanBG", timeWeightedMean);
json.put("ascDesc", ascDesc);
}
@Override
public String toString() {
return "DailyStats{" +
"dateTime=" + dateTime +
", numReadings=" + numReadings +
", simpleMean=" + simpleMean +
", timeWeightedMean=" + timeWeightedMean +
", ascDesc=" + ascDesc +
'}';
}
public JsonNode toJson() {
return json;
}
}