com.digitaldan.harmony.config.HarmonyConfig Maven / Gradle / Ivy
package com.digitaldan.harmony.config;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
public class HarmonyConfig {
@SerializedName("activity")
private List activities = new ArrayList<>();
@SerializedName("device")
private List devices = new ArrayList<>();
private Map content = new HashMap<>();
private Global global;
public String toJson() {
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
return gson.toJson(this);
}
public Map getDeviceLabels() {
Map results = new HashMap();
for (Device device : devices) {
results.put(device.getId(), device.getLabel());
}
return results;
}
public List getActivities() {
return activities;
}
public void setActivities(List activity) {
this.activities = activity;
}
public List getDevices() {
return devices;
}
public void setDevices(List device) {
this.devices = device;
}
public Map getContent() {
return content;
}
public void setContent(Map content) {
this.content = content;
}
public Global getGlobal() {
return global;
}
public void setGlobal(Global global) {
this.global = global;
}
public Activity getActivityById(int result) {
for (Activity activity : activities) {
if (activity.getId() == result) {
return activity;
}
}
return null;
}
public Activity getActivityByName(String label) {
for (Activity activity : activities) {
if (activity.getLabel().equals(label)) {
return activity;
}
}
return null;
}
public Device getDeviceByName(String label) {
for (Device device : devices) {
if (device.getLabel().equals(label)) {
return device;
}
}
return null;
}
public Device getDeviceById(int id) {
for (Device device : devices) {
if (device.getId() == id) {
return device;
}
}
return null;
}
}