Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/device/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class Room {

private int id;
private String name;
private Location location;
private boolean alertState;
private boolean aliveState;
Expand Down Expand Up @@ -36,8 +37,9 @@ public Room(final int id, final Location location, final boolean alertState,
}

public enum JsonEnum {
ID("id"), LOCATION("lc"), ALERT_STATE("ar"), ALIVE_STATE("al"),
LINKS("lk"), STATIC_DEVICE("sd"), DYNAMIC_DEVICE("dd");
ID("id"), NAME("nm"), LOCATION("lc"),
ALERT_STATE("ar"), ALIVE_STATE("al"), LINKS("lk"),
STATIC_DEVICE("sd"), DYNAMIC_DEVICE("dd");

private final String string;

Expand All @@ -55,6 +57,7 @@ public String toString() {
public static Room parse(final JsonElement json) {
final JsonObject jsonObject = json.getAsJsonObject();
final int id = jsonObject.get(JsonEnum.ID.toString()).getAsInt();
final String name = jsonObject.get(JsonEnum.NAME.toString()).getAsString();
final Location location = Location.parse(jsonObject.get(JsonEnum.LOCATION.toString()));
final boolean alertState = jsonObject.get(JsonEnum.ALERT_STATE.toString()).getAsInt() != 0;
final boolean aliveState = jsonObject.get(JsonEnum.ALIVE_STATE.toString()).getAsInt() != 0;
Expand Down Expand Up @@ -109,6 +112,14 @@ protected void setId(int id) {
this.id = id;
}

public String getName() {
return this.name;
}

public void setName(final String name) {
this.name = name;
}

public Location getLocation() {
return location;
}
Expand Down Expand Up @@ -160,6 +171,7 @@ protected void setDynamicDevices(final StringSet dynamicDevices) {
public JsonObject toJson() {
final JsonObject json = new JsonObject();
json.addProperty(JsonEnum.ID.toString(), this.getId());
json.addProperty(JsonEnum.NAME.toString(), this.getName());
json.add(JsonEnum.LOCATION.toString(), this.getLocation().toJson());
json.addProperty(JsonEnum.ALERT_STATE.toString(), this.isAlertState() ? 1 : 0);
json.addProperty(JsonEnum.ALIVE_STATE.toString(), this.isAliveState() ? 1 : 0);
Expand Down