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 | ||
7 | import java.util.function.Function; | |
8 | import java.util.function.Predicate; | |
9 | import java.util.function.Supplier; | |
10 | import java.util.regex.Pattern; | |
11 | ||
12 | import static com.github.dakusui.pcond.core.printable.ExplainablePredicate.explainableStringIsEqualTo; | |
13 | import static com.github.dakusui.pcond.internals.InternalUtils.trivialIdentityFunction; | |
14 | ||
15 | public interface StringChecker<T> extends | |
16 | AbstractObjectChecker< | |
17 | StringChecker<T>, | |
18 | T, | |
19 | String> { | |
20 | default StringChecker<T> containing(String token) { | |
21 |
1
1. containing : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::containing → KILLED |
return this.checkWithPredicate(Predicates.containsString(token)); |
22 | } | |
23 | ||
24 | default StringChecker<T> containingRegexes(String... regexes) { | |
25 |
1
1. startingWith : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::startingWith → KILLED |
return this.checkWithPredicate(Cursors.findRegexes(regexes)); |
26 | } | |
27 | ||
28 | default StringChecker<T> containingRegexes(Pattern... patterns) { | |
29 |
1
1. endingWith : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::endingWith → KILLED |
return this.checkWithPredicate(Cursors.findRegexPatterns(patterns)); |
30 | } | |
31 | ||
32 | /** | |
33 |
1
1. empty : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::empty → KILLED |
* Checks if given tokens are contained by the target value in the given order. |
34 | * @param tokens Tokens | |
35 | * @return | |
36 | */ | |
37 |
1
1. notEmpty : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::notEmpty → NO_COVERAGE |
default StringChecker<T> containingSubstrings(String... tokens) { |
38 | return this.checkWithPredicate(Cursors.findSubstrings(tokens)); | |
39 | } | |
40 | ||
41 |
1
1. equalTo : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::equalTo → KILLED |
default StringChecker<T> startingWith(String prefix) { |
42 | return this.checkWithPredicate(Predicates.startsWith(prefix)); | |
43 | } | |
44 | ||
45 |
1
1. nullOrEmpty : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::nullOrEmpty → KILLED |
default StringChecker<T> endingWith(String prefix) { |
46 | return this.checkWithPredicate(Predicates.endsWith(prefix)); | |
47 | } | |
48 | ||
49 |
1
1. matchingRegex : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::matchingRegex → KILLED |
default StringChecker<T> empty() { |
50 | return this.checkWithPredicate(Predicates.isEmptyString()); | |
51 | } | |
52 | ||
53 |
1
1. equalToIgnoringCase : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::equalToIgnoringCase → KILLED |
default StringChecker<T> notEmpty() { |
54 | return this.checkWithPredicate(Predicates.isEmptyString().negate()); | |
55 | } | |
56 | ||
57 |
1
1. findRegexes : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::findRegexes → KILLED |
default StringChecker<T> equalTo(String string) { |
58 | return this.checkWithPredicate(explainableStringIsEqualTo(string)); | |
59 | } | |
60 | ||
61 |
1
1. findRegexPatterns : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::findRegexPatterns → KILLED |
default StringChecker<T> nullOrEmpty() { |
62 | return this.checkWithPredicate(Predicates.isNullOrEmptyString()); | |
63 | } | |
64 | ||
65 |
1
1. findSubstrings : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::findSubstrings → KILLED |
default StringChecker<T> matchingRegex(String regex) { |
66 | return this.checkWithPredicate(Predicates.matchesRegex(regex)); | |
67 | } | |
68 | ||
69 | default StringChecker<T> equalToIgnoringCase(String s) { | |
70 |
2
1. check : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::check → NO_COVERAGE 2. lambda$check$0 : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker::lambda$check$0 → NO_COVERAGE |
return this.checkWithPredicate(Predicates.equalsIgnoreCase(s)); |
71 | } | |
72 | ||
73 | @SuppressWarnings("unchecked") | |
74 | default StringChecker<T> check(Function<StringChecker<String>, Predicate<String>> phrase) { | |
75 | return this.addCheckPhrase(v -> phrase.apply((StringChecker<String>) v)); | |
76 | } | |
77 | ||
78 | class Impl<T> | |
79 | extends | |
80 | Base<StringChecker<T>, T, String> | |
81 | implements | |
82 | StringChecker<T> { | |
83 | protected Impl(Supplier<T> rootValue, Function<T, String> transformFunction) { | |
84 |
1
1. rebase : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/StringChecker$Impl::rebase → SURVIVED |
super(rootValue, transformFunction); |
85 | } | |
86 | ||
87 | @Override | |
88 | public StringChecker<String> rebase() { | |
89 | return new StringChecker.Impl<>(this::value, trivialIdentityFunction()); | |
90 | } | |
91 | } | |
92 | } | |
Mutations | ||
21 |
1.1 |
|
25 |
1.1 |
|
29 |
1.1 |
|
33 |
1.1 |
|
37 |
1.1 |
|
41 |
1.1 |
|
45 |
1.1 |
|
49 |
1.1 |
|
53 |
1.1 |
|
57 |
1.1 |
|
61 |
1.1 |
|
65 |
1.1 |
|
70 |
1.1 2.2 |
|
84 |
1.1 |