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

torand / FasterSQL / 15071216480

16 May 2025 02:49PM UTC coverage: 69.877% (+2.4%) from 67.475%
15071216480

push

github

web-flow
Merge pull request #30 from torand/access-support

Access support

229 of 414 branches covered (55.31%)

Branch coverage included in aggregate %.

105 of 152 new or added lines in 26 files covered. (69.08%)

3 existing lines in 3 files now uncovered.

1193 of 1621 relevant lines covered (73.6%)

3.92 hits per line

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

30.0
/src/main/java/io/github/torand/fastersql/predicate/LeftOperand.java
1
/*
2
 * Copyright (c) 2024-2025 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.Sql;
19
import io.github.torand.fastersql.expression.Expression;
20
import io.github.torand.fastersql.predicate.comparison.ComparisonPredicates;
21
import io.github.torand.fastersql.statement.SelectStatement;
22
import io.github.torand.fastersql.subquery.ExpressionSubquery;
23

24
import java.util.Collection;
25
import java.util.Optional;
26

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

31
/**
32
 * Defines the left operand of an expression.
33
 */
34
public interface LeftOperand extends Sql {
35

36
    /**
37
     * Creates an equivalence predicate from this left operand and the specified constant value.
38
     * @param value the constant value.
39
     * @return the predicate.
40
     */
41
    default Predicate eq(Object value) {
42
        return ComparisonPredicates.eq(this, value);
4✔
43
    }
44

45
    /**
46
     * Creates an optional equivalence predicate from this left operand and the specified optional value.
47
     * @param value the optional value.
48
     * @return the optional predicate.
49
     */
50
    default OptionalPredicate eq(Optional<?> value) {
51
        requireNonNull(value, "No value specified");
4✔
52
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.eq(this, v)).orElse(null));
13✔
53
    }
54

55
    /**
56
     * Creates an equivalence predicate from this left operand and the specified expression.
57
     * @param expression the expression.
58
     * @return the predicate.
59
     */
60
    default Predicate eq(Expression expression) {
61
        return ComparisonPredicates.eq(this, expression);
4✔
62
    }
63

64
    /**
65
     * Creates an equivalence predicate from this left operand and the specified subquery.
66
     * @param query the subquery.
67
     * @return the predicate.
68
     */
69
    default Predicate eq(SelectStatement query) {
70
        return ComparisonPredicates.eq(this, new ExpressionSubquery(query));
7✔
71
    }
72

73
    /**
74
     * Creates a 'less than' predicate from this left operand and the specified constant value.
75
     * @param value the constant value.
76
     * @return the predicate.
77
     */
78
    default Predicate lt(Object value) {
79
        return ComparisonPredicates.lt(this, value);
4✔
80
    }
81

82
    /**
83
     * Creates an optional 'less than' predicate from this left operand and the specified optional value.
84
     * @param value the optional value.
85
     * @return the optional predicate.
86
     */
87
    default OptionalPredicate lt(Optional<?> value) {
88
        requireNonNull(value, "No value specified");
×
89
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.lt(this, v)).orElse(null));
×
90
    }
91

92
    /**
93
     * Creates a 'less than' predicate from this left operand and the specified expression.
94
     * @param expression the expression.
95
     * @return the predicate.
96
     */
97
    default Predicate lt(Expression expression) {
NEW
98
        return ComparisonPredicates.lt(this, expression);
×
99
    }
100

101
    /**
102
     * Creates a 'less than' predicate from this left operand and the specified subquery.
103
     * @param query the subquery.
104
     * @return the predicate.
105
     */
106
    default Predicate lt(SelectStatement query) {
NEW
107
        return ComparisonPredicates.lt(this, new ExpressionSubquery(query));
×
108
    }
109

110
    /**
111
     * Creates a 'less than or equal' predicate from this left operand and the specified constant value.
112
     * @param value the constant value.
113
     * @return the predicate.
114
     */
115
    default Predicate le(Object value) {
116
        return ComparisonPredicates.le(this, value);
4✔
117
    }
118

119
    /**
120
     * Creates an optional 'less than or equal' predicate from this left operand and the specified optional value.
121
     * @param value the optional value.
122
     * @return the optional predicate.
123
     */
124
    default OptionalPredicate le(Optional<?> value) {
125
        requireNonNull(value, "No value specified");
×
126
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.le(this, v)).orElse(null));
×
127
    }
128

129
    /**
130
     * Creates a 'less than or equal' predicate from this left operand and the specified expression.
131
     * @param expression the expression.
132
     * @return the predicate.
133
     */
134
    default Predicate le(Expression expression) {
NEW
135
        return ComparisonPredicates.le(this, expression);
×
136
    }
137

138
    /**
139
     * Creates a 'less than or equal' predicate from this left operand and the specified subquery.
140
     * @param query the subquery.
141
     * @return the predicate.
142
     */
143
    default Predicate le(SelectStatement query) {
NEW
144
        return ComparisonPredicates.le(this, new ExpressionSubquery(query));
×
145
    }
146

147
    /**
148
     * Creates a 'greater than' predicate from this left operand and the specified constant value.
149
     * @param value the constant value.
150
     * @return the predicate.
151
     */
152
    default Predicate gt(Object value) {
153
        return ComparisonPredicates.gt(this, value);
4✔
154
    }
155

156
    /**
157
     * Creates an optional 'greater than' predicate from this left operand and the specified optional value.
158
     * @param value the optional value.
159
     * @return the optional predicate.
160
     */
161
    default OptionalPredicate gt(Optional<?> value) {
162
        requireNonNull(value, "No value specified");
×
163
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.gt(this, v)).orElse(null));
×
164
    }
165

166
    /**
167
     * Creates a 'greater than' predicate from this left operand and the specified expression.
168
     * @param expression the expression.
169
     * @return the predicate.
170
     */
171
    default Predicate gt(Expression expression) {
172
        return ComparisonPredicates.gt(this, expression);
4✔
173
    }
174

175
    /**
176
     * Creates a 'greater than' predicate from this left operand and the specified subquery.
177
     * @param query the subquery.
178
     * @return the predicate.
179
     */
180
    default Predicate gt(SelectStatement query) {
NEW
181
        return ComparisonPredicates.gt(this, new ExpressionSubquery(query));
×
182
    }
183

184
    /**
185
     * Creates a 'greater than or equal' predicate from this left operand and the specified constant value.
186
     * @param value the constant value.
187
     * @return the predicate.
188
     */
189
    default Predicate ge(Object value) {
190
        return ComparisonPredicates.ge(this, value);
×
191
    }
192

193
    /**
194
     * Creates an optional 'greater than or equal' predicate from this left operand and the specified optional value.
195
     * @param value the optional value.
196
     * @return the optional predicate.
197
     */
198
    default OptionalPredicate ge(Optional<?> value) {
199
        requireNonNull(value, "No value specified");
×
200
        return OptionalPredicate.ofNullable(value.map(v -> ComparisonPredicates.ge(this, v)).orElse(null));
×
201
    }
202

203
    /**
204
     * Creates a 'greater than or equal' predicate from this left operand and the specified expression.
205
     * @param expression the expression.
206
     * @return the predicate.
207
     */
208
    default Predicate ge(Expression expression) {
NEW
209
        return ComparisonPredicates.ge(this, expression);
×
210
    }
211

212
    /**
213
     * Creates a 'greater than or equal' predicate from this left operand and the specified subquery.
214
     * @param query the subquery.
215
     * @return the predicate.
216
     */
217
    default Predicate ge(SelectStatement query) {
NEW
218
        return ComparisonPredicates.ge(this, new ExpressionSubquery(query));
×
219
    }
220

221
    /**
222
     * Creates a 'member of set' predicate from this left operand and the specified array of constant values.
223
     * @param values the constant values.
224
     * @return the predicate.
225
     */
226
    default Predicate in(Object... values) {
227
        requireNonEmpty(values, "No values specified");
6✔
228
        if (values.length == 1) {
4!
229
            return ComparisonPredicates.eq(this, values[0]);
×
230
        } else {
231
            return Predicates.in(this, asList(values));
5✔
232
        }
233
    }
234

235
    /**
236
     * Creates a 'member of set' predicate from this left operand and the specified collection of constant values.
237
     * @param values the constant values.
238
     * @return the predicate.
239
     */
240
    default Predicate in(Collection<?> values) {
241
        requireNonEmpty(values, "No values specified");
×
242
        if (values.size() == 1) {
×
243
            return ComparisonPredicates.eq(this, values.iterator().next());
×
244
        } else {
245
            return Predicates.in(this, values);
×
246
        }
247
    }
248

249
    /**
250
     * Creates an optional 'member of set' predicate from this left operand and the specified optional collection of constant values.
251
     * @param values the optional constant values.
252
     * @return the optional predicate.
253
     */
254
    default OptionalPredicate in(Optional<? extends Collection<?>> values) {
255
        requireNonNull(values, "No values specified");
×
256
        return OptionalPredicate.ofNullable(values.map(v -> {
×
257
            if (v.size() == 1) {
×
258
                return ComparisonPredicates.eq(this, v.iterator().next());
×
259
            } else {
260
                return Predicates.in(this, v);
×
261
            }
262
        }).orElse(null));
×
263
    }
264

265
    /**
266
     * Creates a 'member of set' predicate from this left operand and the specified subquery.
267
     * @param query the subquery.
268
     * @return the predicate.
269
     */
270
    default Predicate in(SelectStatement query) {
NEW
271
        return Predicates.in(this, new ExpressionSubquery(query));
×
272
    }
273

274
    /**
275
     * Creates a pattern matching predicate from this left operand and the specified string pattern.
276
     * @param pattern the string pattern.
277
     * @return the predicate.
278
     */
279
    default Predicate like(String pattern) {
280
        return Predicates.like(this, pattern);
4✔
281
    }
282

283
    /**
284
     * Creates an optional pattern matching predicate from this left operand and the specified optional string pattern.
285
     * @param pattern the optional string pattern.
286
     * @return the optional predicate.
287
     */
288
    default OptionalPredicate like(Optional<String> pattern) {
289
        requireNonNull(pattern, "No pattern specified");
×
290
        return OptionalPredicate.ofNullable(pattern.map(p -> Predicates.like(this, p)).orElse(null));
×
291
    }
292

293
    /**
294
     * Creates an 'is null' predicate from this left operand.
295
     * @return the predicate.
296
     */
297
    default Predicate isNull() {
298
        return Predicates.isNull(this);
3✔
299
    }
300
}
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