• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / mybatis-dynamic-sql / #1521

15 Nov 2023 11:38AM CUT coverage: 100.0%. Remained the same
#1521

push

github

web-flow
Merge pull request #697 from mybatis/renovate/testcontainers-java-monorepo

Update testcontainers-java monorepo to v1.19.2

4517 of 4517 relevant lines covered (100.0%)

1.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/main/java/org/mybatis/dynamic/sql/AbstractTwoValueCondition.java
1
/*
2
 *    Copyright 2016-2023 the original author or authors.
3
 *
4
 *    Licensed under the Apache License, Version 2.0 (the "License");
5
 *    you may not use this file except in compliance with the License.
6
 *    You may obtain a copy of the License at
7
 *
8
 *       https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *    Unless required by applicable law or agreed to in writing, software
11
 *    distributed under the License is distributed on an "AS IS" BASIS,
12
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *    See the License for the specific language governing permissions and
14
 *    limitations under the License.
15
 */
16
package org.mybatis.dynamic.sql;
17

18
import java.util.function.BiFunction;
19
import java.util.function.BiPredicate;
20
import java.util.function.Function;
21
import java.util.function.Predicate;
22
import java.util.function.Supplier;
23

24
public abstract class AbstractTwoValueCondition<T> implements VisitableCondition<T> {
25
    protected final T value1;
26
    protected final T value2;
27

28
    protected AbstractTwoValueCondition(T value1, T value2) {
1✔
29
        this.value1 = value1;
1✔
30
        this.value2 = value2;
1✔
31
    }
1✔
32

33
    public T value1() {
34
        return value1;
1✔
35
    }
36

37
    public T value2() {
38
        return value2;
1✔
39
    }
40

41
    @Override
42
    public <R> R accept(ConditionVisitor<T, R> visitor) {
43
        return visitor.visit(this);
1✔
44
    }
45

46
    protected <S extends AbstractTwoValueCondition<T>> S filterSupport(BiPredicate<? super T, ? super T> predicate,
47
            Supplier<S> emptySupplier, S self) {
48
        if (shouldRender()) {
1✔
49
            return predicate.test(value1, value2) ? self : emptySupplier.get();
1✔
50
        } else {
51
            return self;
1✔
52
        }
53
    }
54

55
    protected <S extends AbstractTwoValueCondition<T>> S filterSupport(Predicate<? super T> predicate,
56
            Supplier<S> emptySupplier, S self) {
57
        return filterSupport((v1, v2) -> predicate.test(v1) && predicate.test(v2), emptySupplier, self);
1✔
58
    }
59

60
    protected <R, S extends AbstractTwoValueCondition<R>> S mapSupport(Function<? super T, ? extends R> mapper1,
61
            Function<? super T, ? extends R> mapper2, BiFunction<R, R, S> constructor, Supplier<S> emptySupplier) {
62
        if (shouldRender()) {
1✔
63
            return constructor.apply(mapper1.apply(value1), mapper2.apply(value2));
1✔
64
        } else {
65
            return emptySupplier.get();
1✔
66
        }
67
    }
68

69
    /**
70
     * If renderable and the values match the predicate, returns this condition. Else returns a condition
71
     *     that will not render.
72
     *
73
     * @param predicate predicate applied to the values, if renderable
74
     * @return this condition if renderable and the values match the predicate, otherwise a condition
75
     *     that will not render.
76
     */
77
    public abstract AbstractTwoValueCondition<T> filter(BiPredicate<? super T, ? super T> predicate);
78

79
    /**
80
     * If renderable and both values match the predicate, returns this condition. Else returns a condition
81
     *     that will not render. This function implements a short-circuiting test. If the
82
     *     first value does not match the predicate, then the second value will not be tested.
83
     *
84
     * @param predicate predicate applied to both values, if renderable
85
     * @return this condition if renderable and the values match the predicate, otherwise a condition
86
     *     that will not render.
87
     */
88
    public abstract AbstractTwoValueCondition<T> filter(Predicate<? super T> predicate);
89

90
    public abstract String operator1();
91

92
    public abstract String operator2();
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc