Merge branch 'feature/device-service' of https://github.com/jazzm0/microservices-demo into feature/device-service

This commit is contained in:
Steinwagner 2019-12-10 18:31:14 +01:00
commit 77ad8fd842

View file

@ -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();