• 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

93.33
/src/main/java/io/github/torand/fastersql/expression/arithmetic/Subtraction.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.arithmetic;
17

18
import io.github.torand.fastersql.Column;
19
import io.github.torand.fastersql.Context;
20
import io.github.torand.fastersql.alias.ColumnAlias;
21
import io.github.torand.fastersql.expression.Expression;
22
import io.github.torand.fastersql.order.OrderExpression;
23
import io.github.torand.fastersql.projection.Projection;
24

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

28
import static io.github.torand.fastersql.util.contract.Requires.requireNonBlank;
29
import static io.github.torand.fastersql.util.lang.StringHelper.nonBlank;
30
import static java.util.Objects.requireNonNull;
31

32
/**
33
 * Implements the subtraction (difference) expression.
34
 */
35
public class Subtraction implements Expression, OrderExpression {
36
    private final Expression minuend;
37
    private final Expression subtrahend;
38
    private final ColumnAlias alias;
39

40
    Subtraction(Expression minuend, Expression subtrahend, String alias) {
2✔
41
        this.minuend = requireNonNull(minuend, "No left operand (minuend) specified");
6✔
42
        this.subtrahend = requireNonNull(subtrahend, "No right operand (subtrahend) specified");
6✔
43
        this.alias = nonBlank(alias) ? new ColumnAlias(alias) : defaultAlias();
12✔
44
    }
1✔
45

46
    // Sql
47

48
    @Override
49
    public String sql(Context context) {
50
        return minuend.sql(context) + " - " + subtrahend.sql(context);
10✔
51
    }
52

53
    @Override
54
    public Stream<Object> params(Context context) {
55
        return Stream.concat(minuend.params(context), subtrahend.params(context));
10✔
56
    }
57

58
    @Override
59
    public Stream<Column> columnRefs() {
60
        return Stream.concat(minuend.columnRefs(), subtrahend.columnRefs());
8✔
61
    }
62

63
    @Override
64
    public Stream<ColumnAlias> aliasRefs() {
NEW
65
        return Stream.concat(minuend.aliasRefs(), subtrahend.aliasRefs());
×
66
    }
67

68
    // Projection
69

70
    @Override
71
    public Projection as(String alias) {
72
        requireNonBlank(alias, "No alias specified");
6✔
73
        return new Subtraction(minuend, subtrahend, alias);
9✔
74
    }
75

76
    @Override
77
    public Optional<ColumnAlias> alias() {
78
        return Optional.ofNullable(alias);
4✔
79
    }
80

81
    private ColumnAlias defaultAlias() {
82
        return ColumnAlias.generate("MINUS_");
3✔
83
    }
84
}
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