summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/Match.java
blob: 4f01c98410e53b8b6e45fbc182361c92e4e060f0 (plain) (blame)
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 design.model;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Match {
    private final Course course;
    private final Date dateScheduled;
    private final LocalDateTime start;
    private final int holeCount;
    private final List<Round> rounds;

    @JsonCreator
    private Match(Course course, Date dateScheduled, LocalDateTime start, int holeCount, List<Round> rounds) {
        this.course = course;
        this.dateScheduled = dateScheduled;
        this.start = start;
        this.holeCount = holeCount;
        this.rounds = rounds;
    }

    public Match(Course course, Date dateScheduled, LocalDateTime start, int holeCount) {
        this.course = course;
        this.dateScheduled = dateScheduled;
        this.start = start;
        this.holeCount = holeCount;
        this.rounds = new ArrayList<>();
    }

    public Course getCourse() {
        return course;
    }

    public Date getDateScheduled() {
        return dateScheduled;
    }

    public LocalDateTime getStart() {
        return start;
    }

    public int getHoleCount() {
        return holeCount;
    }

    public boolean addRound(Round round) {
        return rounds.add(round);
    }

    public Round[] getRounds() {
        return rounds.toArray(Round[]::new);
    }
}