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

torand / FasterSQL / 16990714480

15 Aug 2025 01:12PM UTC coverage: 66.932% (+0.2%) from 66.782%
16990714480

push

github

torand
refactor: cleanup calls + remove obsolete methods

294 of 598 branches covered (49.16%)

Branch coverage included in aggregate %.

11 of 16 new or added lines in 4 files covered. (68.75%)

1641 of 2293 relevant lines covered (71.57%)

3.84 hits per line

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

86.67
/src/main/java/io/github/torand/fastersql/expression/cases/SearchedCaseBuilder.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.expression.cases;
17

18
import io.github.torand.fastersql.expression.Expression;
19
import io.github.torand.fastersql.predicate.Predicate;
20

21
import java.util.ArrayList;
22
import java.util.List;
23

24
import static io.github.torand.fastersql.constant.Constants.$;
25
import static java.util.Objects.requireNonNull;
26

27
/**
28
 * Builder of searched CASE expressions.
29
 */
30
public class SearchedCaseBuilder {
31
    private final List<SearchedWhenThen> whenThenClauses = new ArrayList<>();
5✔
32
    private Expression elseExpression;
33

34
    SearchedCaseBuilder() {
2✔
35
    }
1✔
36

37
    /**
38
     * Creates a WHEN-THEN clause.
39
     * @param whenPredicate the WHEN predicate.
40
     * @return the WHEN-THEN builder.
41
     */
42
    public SearchedWhenThenBuilder when(Predicate whenPredicate) {
43
        requireNonNull(whenPredicate, "No when predicate specified");
4✔
44
        return new SearchedWhenThenBuilder(this, whenPredicate);
6✔
45
    }
46

47
    /**
48
     * Adds an ELSE clause.
49
     * @param elseExpression the ELSE expression.
50
     * @return the modified CASE expression.
51
     */
52
    public SearchedCaseBuilder else_(Expression elseExpression) {
53
        this.elseExpression = requireNonNull(elseExpression, "No else expression specified");
6✔
54
        return this;
2✔
55
    }
56

57
    /**
58
     * Adds an ELSE clause.
59
     * @param elseConstant the ELSE constant value.
60
     * @return the modified CASE expression.
61
     */
62
    public SearchedCaseBuilder else_(String elseConstant) {
63
        requireNonNull(elseConstant, "No else constant specified");
4✔
64
        return else_($(elseConstant));
5✔
65
    }
66

67
    /**
68
     * Adds an ELSE clause.
69
     * @param elseConstant the ELSE constant value.
70
     * @return the modified CASE expression.
71
     */
72
    public SearchedCaseBuilder else_(Number elseConstant) {
NEW
73
        requireNonNull(elseConstant, "No else constant specified");
×
NEW
74
        return else_($(elseConstant));
×
75
    }
76

77
    /**
78
     * Creates the searched CASE expression.
79
     * @return the searched CASE expression.
80
     */
81
    public SearchedCase end() {
82
        return new SearchedCase(whenThenClauses, elseExpression, null);
9✔
83
    }
84

85
    void addWhenThenClause(SearchedWhenThen whenThenClause) {
86
        requireNonNull(whenThenClause, "No when-then clause specified");
4✔
87
        this.whenThenClauses.add(whenThenClause);
5✔
88
    }
1✔
89
}
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