|
|
@@ -2,21 +2,21 @@ import java.util.EnumSet;
|
|
2
|
2
|
import java.util.List;
|
|
3
|
3
|
import java.util.stream.Collectors;
|
|
4
|
4
|
|
|
5
|
|
-public class Allergies {
|
|
|
5
|
+class Allergies {
|
|
6
|
6
|
|
|
7
|
7
|
private int score;
|
|
8
|
8
|
|
|
9
|
|
- public Allergies(int score) {
|
|
|
9
|
+ Allergies(int score) {
|
|
10
|
10
|
this.score = score;
|
|
11
|
11
|
}
|
|
12
|
12
|
|
|
13
|
|
- public List<Allergen> getList() {
|
|
|
13
|
+ List<Allergen> getList() {
|
|
14
|
14
|
return EnumSet.allOf(Allergen.class).stream()
|
|
15
|
15
|
.filter(this::isAllergicTo)
|
|
16
|
16
|
.collect(Collectors.toList());
|
|
17
|
17
|
}
|
|
18
|
18
|
|
|
19
|
|
- public boolean isAllergicTo(Allergen allergen) {
|
|
|
19
|
+ boolean isAllergicTo(Allergen allergen) {
|
|
20
|
20
|
return (score & allergen.getScore()) == allergen.getScore();
|
|
21
|
21
|
}
|
|
22
|
22
|
}
|