• 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

89.47
/src/main/java/io/github/torand/fastersql/function/singlerow/SingleRowFunctions.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.function.singlerow;
17

18
import io.github.torand.fastersql.expression.Expression;
19

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

23
import static java.util.Objects.nonNull;
24
import static java.util.Objects.requireNonNull;
25

26
/**
27
 * Provides factory methods for single row functions.
28
 */
29
public final class SingleRowFunctions {
30
    private SingleRowFunctions() {}
31

32
    /**
33
     * Creates the upper case function for a string expression.
34
     * @param expression the string expression.
35
     * @return the string function.
36
     */
37
    public static Upper upper(Expression expression) {
38
        return new Upper(expression, null);
6✔
39
    }
40

41
    /**
42
     * Creates the lower case function for a string expression.
43
     * @param expression the string expression.
44
     * @return the string function.
45
     */
46
    public static Lower lower(Expression expression) {
47
        return new Lower(expression, null);
6✔
48
    }
49

50
    /**
51
     * Creates the string to decimal number conversion function for an expression.
52
     * @param expression the string expression.
53
     * @param precision the total number of digits (including decimals).
54
     * @param scale the number of decimals.
55
     * @return the conversion function.
56
     */
57
    public static ToNumber toNumber(Expression expression, int precision, int scale) {
UNCOV
58
        return new ToNumber(expression, precision, scale, null);
×
59
    }
60

61
    /**
62
     * Creates the string to integer number conversion function for an expression.
63
     * @param expression the string expression.
64
     * @param precision the total number of digits.
65
     * @return the conversion function.
66
     */
67
    public static ToNumber toNumber(Expression expression, int precision) {
68
        return new ToNumber(expression, precision, 0, null);
8✔
69
    }
70

71
    /**
72
     * Creates the substring function for a string expression.
73
     * @param expression the string expression.
74
     * @return the string function.
75
     */
76
    public static Substring substring(Expression expression, int startPos, int length) {
77
        return new Substring(expression, startPos, length, null);
8✔
78
    }
79

80
    /**
81
     * Creates the timestamp/number to string conversion function for an expression.
82
     * @param expression the timestamp or number expression.
83
     * @param format the format specifier.
84
     * @return the conversion function.
85
     */
86
    public static ToChar toChar(Expression expression, String format) {
87
        return new ToChar(expression, format, null);
7✔
88
    }
89

90
    /**
91
     * Creates the concatenation function for string expressions.
92
     * @param expression1 the first string expression.
93
     * @param expression2 the second string expression.
94
     * @param otherExpressions the additional string expressions.
95
     * @return the string function.
96
     */
97
    public static Concat concat(Expression expression1, Expression expression2, Expression... otherExpressions) {
98
        List<Expression> expressions = new ArrayList<>();
4✔
99
        expressions.add(requireNonNull(expression1, "First expression is null"));
7✔
100
        expressions.add(requireNonNull(expression2, "Second expression is null"));
7✔
101
        if (nonNull(otherExpressions)) {
3!
102
            expressions.addAll(List.of(otherExpressions));
5✔
103
        }
104

105
        return new Concat(expressions, null);
6✔
106
    }
107

108
    /**
109
     * Creates the length function for a string expression.
110
     * @param expression the string expression.
111
     * @return the string function.
112
     */
113
    public static Length length(Expression expression) {
114
        return new Length(expression, null);
6✔
115
    }
116

117
    /**
118
     * Creates the round function for a numeric expression.
119
     * @param expression the numeric expression.
120
     * @return the numeric function.
121
     */
122
    public static Round round(Expression expression) {
123
        return new Round(expression, null);
6✔
124
    }
125

126
    /**
127
     * Creates the absolute value function for a numeric expression.
128
     * @param expression the numeric expression.
129
     * @return the numeric function.
130
     */
131
    public static Abs abs(Expression expression) {
132
        return new Abs(expression, null);
6✔
133
    }
134

135
    /**
136
     * Creates the ceiling function for a numeric expression.
137
     * @param expression the numeric expression.
138
     * @return the numeric function.
139
     */
140
    public static Ceil ceil(Expression expression) {
141
        return new Ceil(expression, null);
6✔
142
    }
143

144
    /**
145
     * Creates the floor function for a numeric expression.
146
     * @param expression the numeric expression.
147
     * @return the numeric function.
148
     */
149
    public static Floor floor(Expression expression) {
150
        return new Floor(expression, null);
6✔
151
    }
152
}
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