add device model

This commit is contained in:
Tibor Tarnai 2019-12-10 16:37:13 +01:00
parent 450b1393b2
commit de04d31825
2 changed files with 48 additions and 1 deletions

View file

@ -0,0 +1,5 @@
package com.sap.tamagotchi.model;
public enum Color {
RED, YELLOW, BLUE, GREEN
}

View file

@ -1,4 +1,46 @@
package com.sap.tamagotchi.model;
public class Device {
import java.time.Instant;
import java.util.Collection;
import java.util.Collections;
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
public class Device extends Thread {
private final String getDeviceId = UUID.randomUUID().toString();
private final String owner;
private final Color color;
private final Instant born = Instant.now();
private final Queue<String> messages = new ConcurrentLinkedQueue<String>();
public Device(String owner, Color color) {
this.owner = owner;
this.color = color;
}
public String getDeviceId() {
return getDeviceId;
}
public String getOwner() {
return owner;
}
public Color getColor() {
return color;
}
public Instant getBorn() {
return born;
}
public boolean hasMessages() {
return !messages.isEmpty();
}
public Collection<IoTMessage> getMessages() {
return Collections.emptyList();
}
}