1 | package com.github.dakusui.pcond.core.fluent.builtins; | |
2 | ||
3 | import com.github.dakusui.pcond.core.fluent.AbstractObjectChecker; | |
4 | import com.github.dakusui.pcond.experimentals.cursor.Cursors; | |
5 | import com.github.dakusui.pcond.forms.Predicates; | |
6 | import com.github.dakusui.pcond.forms.Printables; | |
7 | ||
8 | import java.util.Arrays; | |
9 | import java.util.List; | |
10 | import java.util.Objects; | |
11 | import java.util.function.Function; | |
12 | import java.util.function.Predicate; | |
13 | import java.util.function.Supplier; | |
14 | import java.util.stream.Collectors; | |
15 | ||
16 | import static com.github.dakusui.pcond.internals.InternalUtils.trivialIdentityFunction; | |
17 | ||
18 | public interface ListChecker< | |
19 | T, | |
20 | E | |
21 | > extends | |
22 | AbstractObjectChecker< | |
23 | ListChecker<T, E>, | |
24 | T, | |
25 | List<E>> { | |
26 | default ListChecker<T, E> isEmpty() { | |
27 |
1
1. isEmpty : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::isEmpty → KILLED |
return checkWithPredicate(Predicates.isEmpty()); |
28 | } | |
29 | ||
30 | default ListChecker<T, E> isNotEmpty() { | |
31 |
1
1. isNotEmpty : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::isNotEmpty → KILLED |
return checkWithPredicate(Predicates.not(Predicates.isEmpty())); |
32 | } | |
33 | ||
34 | default ListChecker<T, E> contains(E element) { | |
35 |
1
1. contains : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::contains → KILLED |
return checkWithPredicate(Predicates.contains(element)); |
36 | } | |
37 | ||
38 | @SuppressWarnings("unchecked") | |
39 | default ListChecker<T, E> findElementsInOrderBy(List<Predicate<E>> predicates) { | |
40 |
1
1. findElementsInOrderBy : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::findElementsInOrderBy → KILLED |
return checkWithPredicate(Cursors.findElements(predicates.toArray(new Predicate[0]))); |
41 | } | |
42 | ||
43 | @SuppressWarnings("unchecked") | |
44 | default ListChecker<T, E> findElementsInOrder(E... elements) { | |
45 |
1
1. findElementsInOrder : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::findElementsInOrder → KILLED |
return this.findElementsInOrderBy( |
46 | Arrays.stream(elements) | |
47 |
3
1. lambda$findElementsInOrder$1 : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::lambda$findElementsInOrder$1 → SURVIVED 2. lambda$null$0 : replaced boolean return with false for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::lambda$null$0 → NO_COVERAGE 3. lambda$null$0 : replaced boolean return with true for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::lambda$null$0 → NO_COVERAGE |
.map(v -> Printables.predicate("[" + v + "]", e -> Objects.equals(v, e))) |
48 |
1
1. lambda$findElementsInOrder$2 : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ListChecker::lambda$findElementsInOrder$2 → SURVIVED |
.map(p -> (Predicate<E>) p) |
49 | .collect(Collectors.toList())); | |
50 | } | |
51 | ||
52 | class Impl< | |
53 | T, | |
54 | E | |
55 | > extends Base< | |
56 | ListChecker<T, E>, | |
57 | T, | |
58 | List<E>> implements | |
59 | ListChecker<T, E> { | |
60 | public Impl(Supplier<T> rootValue, Function<T, List<E>> transformFunction) { | |
61 | super(rootValue, transformFunction); | |
62 | } | |
63 | ||
64 | @Override | |
65 | protected ListChecker<List<E>, E> rebase() { | |
66 |
1
1. rebase : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ListChecker$Impl::rebase → SURVIVED |
return new ListChecker.Impl<>(this::value, trivialIdentityFunction()); |
67 | } | |
68 | } | |
69 | } | |
Mutations | ||
27 |
1.1 |
|
31 |
1.1 |
|
35 |
1.1 |
|
40 |
1.1 |
|
45 |
1.1 |
|
47 |
1.1 2.2 3.3 |
|
48 |
1.1 |
|
66 |
1.1 |