summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/statistics/HoleStats.java
blob: 2c023b40231fc7525b8d948ffc8c9aa67c5d4286 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package design.model.statistics;

import java.util.Arrays;

import design.model.Hole;
import design.model.Round;

public class HoleStats extends StatisticsDecorator{
    private Hole target_hole;

    public HoleStats(Statistics wrapped_statistics, Hole target_hole){
        super(wrapped_statistics);
        this.target_hole = target_hole;
    }

    @Override
    public Round[] getRounds(){
        return Arrays.stream(super.getRounds())
                        .filter(round -> round.getCourse().getHoles().stream().anyMatch(hole -> hole.equals(target_hole)))
                        .toArray(Round[]::new);
    }
}