File tree Expand file tree Collapse file tree 1 file changed +27
-9
lines changed
src/main/kotlin/spp/protocol/artifact/metrics Expand file tree Collapse file tree 1 file changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -25,20 +25,38 @@ import java.time.format.DateTimeFormatter
25
25
* @since 0.7.6
26
26
* @author [Brandon Fergerson](mailto:[email protected] )
27
27
*/
28
- enum class MetricStep ( val formatter : DateTimeFormatter ) {
29
- SECOND ( DateTimeFormatter .ofPattern( " yyyy-MM-dd HHmmss " ).withZone( ZoneOffset . UTC )) ,
30
- MINUTE ( DateTimeFormatter .ofPattern( " yyyy-MM-dd HHmm " ).withZone( ZoneOffset . UTC )) ,
31
- HOUR ( DateTimeFormatter .ofPattern( " yyyy-MM-dd HH " ).withZone( ZoneOffset . UTC )) ,
32
- DAY ( DateTimeFormatter .ofPattern( " yyyy-MM-dd " ).withZone( ZoneOffset . UTC )) ;
28
+ enum class MetricStep {
29
+ SECOND ,
30
+ MINUTE ,
31
+ HOUR ,
32
+ DAY ;
33
33
34
- val seconds: Int
35
- get() = when (this ) {
34
+ val seconds: Int by lazy {
35
+ when (this ) {
36
36
SECOND -> 1
37
37
MINUTE -> 60
38
38
HOUR -> 3600
39
39
DAY -> 86400
40
40
}
41
+ }
41
42
42
- val milliseconds: Int
43
- get() = seconds * 1000
43
+ val milliseconds: Int by lazy { seconds * 1000 }
44
+
45
+ val formatter: DateTimeFormatter by lazy {
46
+ when (this ) {
47
+ SECOND -> DateTimeFormatter .ofPattern(" yyyy-MM-dd HHmmss" ).withZone(ZoneOffset .UTC )
48
+ MINUTE -> DateTimeFormatter .ofPattern(" yyyy-MM-dd HHmm" ).withZone(ZoneOffset .UTC )
49
+ HOUR -> DateTimeFormatter .ofPattern(" yyyy-MM-dd HH" ).withZone(ZoneOffset .UTC )
50
+ DAY -> DateTimeFormatter .ofPattern(" yyyy-MM-dd" ).withZone(ZoneOffset .UTC )
51
+ }
52
+ }
53
+
54
+ val bucketFormatter: DateTimeFormatter by lazy {
55
+ when (this ) {
56
+ SECOND -> DateTimeFormatter .ofPattern(" yyyyMMddHHmmss" ).withZone(ZoneOffset .UTC )
57
+ MINUTE -> DateTimeFormatter .ofPattern(" yyyyMMddHHmm" ).withZone(ZoneOffset .UTC )
58
+ HOUR -> DateTimeFormatter .ofPattern(" yyyyMMddHH" ).withZone(ZoneOffset .UTC )
59
+ DAY -> DateTimeFormatter .ofPattern(" yyyyMMdd" ).withZone(ZoneOffset .UTC )
60
+ }
61
+ }
44
62
}
You can’t perform that action at this time.
0 commit comments