add healthScore
This commit is contained in:
parent
a207d663a7
commit
693d06c5e5
1 changed files with 17 additions and 0 deletions
|
@ -22,6 +22,8 @@ public class Device {
|
|||
private final Color color;
|
||||
@JsonProperty("born")
|
||||
private final Instant born = Instant.now();
|
||||
@JsonProperty("healthScore")
|
||||
private int healthScore = 100;
|
||||
private final Queue<IoTMessage> messages = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public Device(String owner, Color color) {
|
||||
|
@ -49,6 +51,21 @@ public class Device {
|
|||
return born;
|
||||
}
|
||||
|
||||
@JsonProperty("healthScore")
|
||||
public int getHealthScore() {
|
||||
return healthScore;
|
||||
}
|
||||
|
||||
@JsonProperty("isAlive")
|
||||
public boolean isAlive() {
|
||||
return healthScore > 1;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void changeHealthScore(int delta) {
|
||||
this.healthScore += delta;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasMessages() {
|
||||
return !messages.isEmpty();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue