package se.chalmers.dat255.grupp12;
import com.google.gson.Gson;
public class Modification {
private String action;
private Task task;
private TaskList list;
private long listID;
private long time;
private Change change;
private long id;
public Modification() {} // For serialization.
/**
* Change contains three Strings, type, from and to where:
* type = The type of change (add/remove/update a task/list)
* from = The value that the object changes from
* to = The value that the object changes to
*/
public static class Change {
private String type;
private String from;
private String to;
public Change(String type, String from, String to) {
this.type = type;
this.from = from;
this.to = to;
}
public String getType() {
return type;
}
private Change(){} // For serialization.
public String getFrom() {
return from;
}
public String getTo() {
return to;
}
}
public Change getChange() {
return change;
}
public Task getTask() {
return task;
}
public int getListId() {
return (int)listID;
}
public String getAction() {
return action;
}
public int getTaskId(){
return (int)id;
}
public TaskList getList() {
return list;
}
/**
* Returns the modification as JSON, as a workaround for the retrofit json parser
* being quite funky in its serializing.
* @return the modification in JSON format.
*/
@Override
public String toString() {
Gson gson = new Gson();
return gson.toJson(this, Modification.class);
}
}