summaryrefslogtreecommitdiff
path: root/python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/format/Course.java
blob: e124a6eb305d1a3fc6758068988d6be5d6648eef (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
58
59
60
61
package org.jetbrains.plugins.coursecreator.format;

import com.google.gson.annotations.Expose;
import com.intellij.psi.PsiDirectory;
import org.jetbrains.annotations.NotNull;

import java.util.*;

public class Course {
  @Expose public List<Lesson> lessons = new ArrayList<Lesson>();
  @Expose public String description;

  @Expose public String name;
  @Expose public String author;

  public Map<String, Lesson> myLessonsMap = new HashMap<String, Lesson>();

  public Map<String, Lesson> getLessonsMap() {
    return myLessonsMap;
  }

  public Lesson getLesson(@NotNull final  String name) {
    return myLessonsMap.get(name);
  }


  public Course() {
  }

  public Course(@NotNull final String name, @NotNull final String author, @NotNull final String description) {
    this.description = description;
    this.name = name;
    this.author = author;
  }

  public List<Lesson> getLessons() {
    return lessons;
  }

  public void addLesson(@NotNull final Lesson lesson, @NotNull final PsiDirectory directory) {
    lessons.add(lesson);
    myLessonsMap.put(directory.getName(), lesson);
  }

  public String getName() {
    return name;
  }

  public String getDescription() {
    return description;
  }

  public void init() {
    lessons.clear();
    for (Lesson lesson: myLessonsMap.values()) {
      lessons.add(lesson);
      lesson.init();
    }
    Collections.sort(lessons);
  }
}