Refactored Task class
- Now crash reports have stacktrace - Minor changes
This commit is contained in:
parent
361d795ab1
commit
5a521fc131
@ -13,9 +13,9 @@ public abstract class Task
|
|||||||
|
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
|
|
||||||
ArrayList<Task> requiredTasks = new ArrayList<Task>();
|
ArrayList<Task> requiredTasks = new ArrayList<>();
|
||||||
|
|
||||||
public Task(String id) {
|
protected Task(String id) {
|
||||||
super(id);
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,17 +23,17 @@ public abstract class Task
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (!canRun()) {
|
if (!canRun()) {
|
||||||
|
|
||||||
ArrayList<Task> UndoneTasks = new ArrayList<Task>();
|
ArrayList<Task> undoneTasks = new ArrayList<>();
|
||||||
for (Task j : requiredTasks) {
|
for (Task j : requiredTasks) {
|
||||||
if (!j.isDone()) {
|
if (!j.isDone()) {
|
||||||
UndoneTasks.add(j);
|
undoneTasks.add(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
throw CrashReports.report(null,
|
throw CrashReports.report(new Throwable(),
|
||||||
"The following required Tasks are not done:\n%s",
|
"The following required Tasks are not done:\n%s",
|
||||||
StringUtil.iterableToString(UndoneTasks, "\n"));
|
StringUtil.iterableToString(undoneTasks, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
perform();
|
perform();
|
||||||
@ -45,8 +45,8 @@ public abstract class Task
|
|||||||
protected abstract void perform();
|
protected abstract void perform();
|
||||||
|
|
||||||
public void addRequiredTask(Task task) {
|
public void addRequiredTask(Task task) {
|
||||||
if (task.getId() == this.getId()) {
|
if (task.equals(this)) {
|
||||||
throw CrashReports.report(null,
|
throw CrashReports.report(new Throwable(),
|
||||||
"It is impossible for the Task (%s) to require itself.",
|
"It is impossible for the Task (%s) to require itself.",
|
||||||
this.getId());
|
this.getId());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user