summaryrefslogtreecommitdiff
path: root/python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/format/Task.java
blob: 886add86ceb4aadedaf5f16b620967632f4334e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.jetbrains.plugins.coursecreator.format;

import com.google.gson.annotations.Expose;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.coursecreator.CCProjectService;

import java.util.HashMap;
import java.util.Map;

public class Task implements Comparable{
  @Expose public String name;
  @Expose public Map<String, TaskFile> task_files = new HashMap<String, TaskFile>();
  public int myIndex;

  public Task() {}

  public Task(@NotNull final String name) {
    this.name = name;
  }

  public int getIndex() {
    return myIndex;
  }

  public void addTaskFile(@NotNull final String name, int index) {
    TaskFile taskFile = new TaskFile();
    taskFile.setIndex(index);
    task_files.put(name, taskFile);
  }

  public TaskFile getTaskFile(@NotNull final String name) {
    String fileName = CCProjectService.getRealTaskFileName(name);
    return fileName != null ? task_files.get(fileName) : null;
  }

  public void setIndex(int index) {
    myIndex = index;
  }

  public Map<String, TaskFile> getTaskFiles() {
    return task_files;
  }

  public boolean isTaskFile(String name) {
    return task_files.get(name) != null;
  }

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

  @Override
  public int compareTo(@NotNull Object o) {
    Task task = (Task) o;
    return myIndex - task.getIndex();
  }
}