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

torand / FasterSQL / 12893661530

21 Jan 2025 06:40PM UTC coverage: 50.829%. Remained the same
12893661530

push

github

torand
refactor: rename expression -> condition

104 of 304 branches covered (34.21%)

Branch coverage included in aggregate %.

81 of 211 new or added lines in 24 files covered. (38.39%)

3 existing lines in 2 files now uncovered.

601 of 1083 relevant lines covered (55.49%)

2.91 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/condition/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.condition;
17

18
import io.github.torand.fastersql.Field;
19
import io.github.torand.fastersql.Sql;
20
import io.github.torand.fastersql.condition.comparison.ComparisonConditions;
21
import io.github.torand.fastersql.statement.SelectStatement;
22
import io.github.torand.fastersql.subquery.Subquery;
23

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

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

32
public interface LeftOperand extends Sql {
33
    Stream<Field> fields();
34

35
    default Condition eq(Object value) {
36
        return ComparisonConditions.eq(this, value);
4✔
37
    }
38

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

44
    default Condition eq(Field other) {
NEW
45
        return ComparisonConditions.eq(this, other);
×
46
    }
47

48
    default Condition eq(SelectStatement inner) {
49
        return ComparisonConditions.eq(this, new Subquery(inner));
7✔
50
    }
51

52
    default Condition lt(Object value) {
NEW
53
        return ComparisonConditions.lt(this, value);
×
54
    }
55

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

61
    default Condition lt(Field other) {
NEW
62
        return ComparisonConditions.lt(this, other);
×
63
    }
64

65
    default Condition le(Object value) {
NEW
66
        return ComparisonConditions.le(this, value);
×
67
    }
68

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

74
    default Condition le(Field other) {
NEW
75
        return ComparisonConditions.le(this, other);
×
76
    }
77

78
    default Condition gt(Object value) {
NEW
79
        return ComparisonConditions.gt(this, value);
×
80
    }
81

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

87
    default Condition gt(Field other) {
NEW
88
        return ComparisonConditions.gt(this, other);
×
89
    }
90

91
    default Condition ge(Object value) {
NEW
92
        return ComparisonConditions.ge(this, value);
×
93
    }
94

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

100
    default Condition ge(Field other) {
NEW
101
        return ComparisonConditions.ge(this, other);
×
102
    }
103

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

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

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

133
    default Condition like(String pattern) {
134
        return ComparisonConditions.like(this, pattern);
4✔
135
    }
136

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