-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathStatisticMessage.java
More file actions
36 lines (28 loc) · 899 Bytes
/
StatisticMessage.java
File metadata and controls
36 lines (28 loc) · 899 Bytes
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
package com.example.cryptotrading;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import java.time.Instant;
import static lombok.AccessLevel.PRIVATE;
@Data
@FieldDefaults(level = PRIVATE, makeFinal = true)
public class StatisticMessage {
long timestamp;
float data;
String currency;
StatisticMessage.Type type;
public StatisticMessage(float data, String currency, Type type) {
this.timestamp = Instant.now().toEpochMilli();
this.data = data;
this.currency = currency;
this.type = type;
}
public enum Type {
PRICE, AVG
}
public static StatisticMessage avg(float avg, String currency) {
return new StatisticMessage(avg, currency, Type.AVG);
}
public static StatisticMessage price(float price, String currency) {
return new StatisticMessage(price, currency, Type.PRICE);
}
}