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

torand / FasterSQL / 12970217277

26 Jan 2025 01:31AM UTC coverage: 49.458%. Remained the same
12970217277

push

github

torand
refactor: condition -> predicate

108 of 322 branches covered (33.54%)

Branch coverage included in aggregate %.

58 of 137 new or added lines in 12 files covered. (42.34%)

3 existing lines in 2 files now uncovered.

622 of 1154 relevant lines covered (53.9%)

2.85 hits per line

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

20.45
/src/main/java/io/github/torand/fastersql/predicate/LeftOperand.java
1
/*
2
 * Copyright (c) 2024 Tore Eide Andersen
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
 *      http://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 io.github.torand.fastersql.predicate;
17

18
import io.github.torand.fastersql.Field;
19
import io.github.torand.fastersql.Sql;
20
import io.github.torand.fastersql.expression.Expression;
21
import io.github.torand.fastersql.predicate.comparison.ComparisonPredicates;
22
import io.github.torand.fastersql.statement.SelectStatement;
23
import io.github.torand.fastersql.subquery.Subquery;
24

25
import java.util.Collection;
26
import java.util.Optional;
27
import java.util.stream.Stream;
28

29
import static io.github.torand.fastersql.util.contract.Requires.requireNonEmpty;
30
import static java.util.Arrays.asList;
31
import static java.util.Objects.requireNonNull;
32

33
public interface LeftOperand extends Sql {
34
    Stream<Field> fieldRefs();
35

36
    default Predicate eq(Object value) {
37
        return ComparisonPredicates.eq(this, value);
4✔
38
    }
39

40
    default OptionalPredicate eq(Optional<?> value) {
41
        requireNonNull(value, "No value specified");
4✔
42
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.eq(this, v)).orElse(null));
13✔
43
    }
44

45
    default Predicate eq(Expression expression) {
NEW
46
        return ComparisonPredicates.eq(this, expression);
×
47
    }
48

49
    default Predicate eq(SelectStatement inner) {
50
        return ComparisonPredicates.eq(this, new Subquery(inner));
7✔
51
    }
52

53
    default Predicate lt(Object value) {
NEW
54
        return ComparisonPredicates.lt(this, value);
×
55
    }
56

57
    default OptionalPredicate lt(Optional<?> value) {
NEW
58
        requireNonNull(value, "No value specified");
×
NEW
59
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.lt(this, v)).orElse(null));
×
60
    }
61

62
    default Predicate lt(Expression other) {
NEW
63
        return ComparisonPredicates.lt(this, other);
×
64
    }
65

66
    default Predicate le(Object value) {
NEW
67
        return ComparisonPredicates.le(this, value);
×
68
    }
69

70
    default OptionalPredicate le(Optional<?> value) {
NEW
71
        requireNonNull(value, "No value specified");
×
NEW
72
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.le(this, v)).orElse(null));
×
73
    }
74

75
    default Predicate le(Expression other) {
NEW
76
        return ComparisonPredicates.le(this, other);
×
77
    }
78

79
    default Predicate gt(Object value) {
NEW
80
        return ComparisonPredicates.gt(this, value);
×
81
    }
82

83
    default OptionalPredicate gt(Optional<?> value) {
NEW
84
        requireNonNull(value, "No value specified");
×
NEW
85
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.gt(this, v)).orElse(null));
×
86
    }
87

88
    default Predicate gt(Expression other) {
NEW
89
        return ComparisonPredicates.gt(this, other);
×
90
    }
91

92
    default Predicate ge(Object value) {
NEW
93
        return ComparisonPredicates.ge(this, value);
×
94
    }
95

96
    default OptionalPredicate ge(Optional<?> value) {
NEW
97
        requireNonNull(value, "No value specified");
×
NEW
98
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.ge(this, v)).orElse(null));
×
99
    }
100

101
    default Predicate ge(Expression other) {
NEW
102
        return ComparisonPredicates.ge(this, other);
×
103
    }
104

105
    default Predicate in(Object... values) {
106
        requireNonEmpty(values, "No values specified");
6✔
107
        if (values.length == 1) {
4!
NEW
108
            return ComparisonPredicates.eq(this, values[0]);
×
109
        } else {
110
            return Predicates.in(this, asList(values));
5✔
111
        }
112
    }
113

114
    default Predicate in(Collection<?> values) {
NEW
115
        requireNonEmpty(values, "No values specified");
×
NEW
116
        if (values.size() == 1) {
×
NEW
117
            return ComparisonPredicates.eq(this, values.iterator().next());
×
118
        } else {
NEW
119
            return Predicates.in(this, values);
×
120
        }
121
    }
122

123
    default OptionalPredicate in(Optional<? extends Collection<?>> values) {
NEW
124
        requireNonNull(values, "No values specified");
×
NEW
125
        return OptionalPredicate.ofNullable(values.map(v -> {
×
NEW
126
            if (v.size() == 1) {
×
NEW
127
                return ComparisonPredicates.eq(this, v.iterator().next());
×
128
            } else {
NEW
129
                return Predicates.in(this, v);
×
130
            }
NEW
131
        }).orElse(null));
×
132
    }
133

134
    default Predicate like(String pattern) {
135
        return Predicates.like(this, pattern);
4✔
136
    }
137

138
    default OptionalPredicate like(Optional<String> pattern) {
NEW
139
        requireNonNull(pattern, "No pattern specified");
×
NEW
140
        return OptionalPredicate.ofNullable(pattern.map(p -> Predicates.like(this, p)).orElse(null));
×
141
    }
142
}
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

© 2026 Coveralls, Inc