1 package fr.ifremer.tutti.persistence.entities.protocol;
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 import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
28
29 import java.util.List;
30 import java.util.function.Predicate;
31
32 public class SpeciesProtocols extends AbstractSpeciesProtocols {
33
34 public static Predicate<SpeciesProtocol> speciesProtocolWhoseCategoryIsMandatoryPredicate(Caracteristic caracteristic) {
35 return new SpeciesProtocolWhoseCategoryIsMandatoryPredicate(caracteristic);
36 }
37
38 private static class SpeciesProtocolWhoseCategoryIsMandatoryPredicate implements Predicate<SpeciesProtocol> {
39
40 private final Integer caracteristicId;
41
42 SpeciesProtocolWhoseCategoryIsMandatoryPredicate(Caracteristic caracteristic) {
43 this.caracteristicId = caracteristic.getIdAsInt();
44 }
45
46 @Override
47 public boolean test(SpeciesProtocol input) {
48 List<Integer> mandatorySampleCategoryId = input.getMandatorySampleCategoryId();
49 return mandatorySampleCategoryId != null && mandatorySampleCategoryId.contains(caracteristicId);
50 }
51 }
52 }