-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathParticipants.java
More file actions
33 lines (24 loc) · 910 Bytes
/
Participants.java
File metadata and controls
33 lines (24 loc) · 910 Bytes
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
package nextstep.ladder.model;
import java.util.List;
import java.util.stream.Collectors;
public class Participants {
private static final String DELIMITER = ",";
private final List<Participant> participants;
public Participants(String inputParticipants) {
this.participants = createParticipants(parseInputParticipants(inputParticipants));
}
private List<String> parseInputParticipants(String inputParticipants) {
return List.of(inputParticipants.split(DELIMITER));
}
private List<Participant> createParticipants(List<String> inputParticipants) {
return inputParticipants.stream()
.map(Participant::new)
.collect(Collectors.toList());
}
public Integer getNumbersOfParticipants() {
return participants.size();
}
public List<Participant> getParticipants() {
return participants;
}
}