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

torand / FasterSQL / 13411942092

19 Feb 2025 11:56AM UTC coverage: 61.269% (-0.7%) from 61.922%
13411942092

push

github

torand
chore: prepare release

161 of 346 branches covered (46.53%)

Branch coverage included in aggregate %.

872 of 1340 relevant lines covered (65.07%)

3.43 hits per line

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

76.92
/src/main/java/io/github/torand/fastersql/constant/GenericConstant.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.constant;
17

18
import io.github.torand.fastersql.Context;
19
import io.github.torand.fastersql.Field;
20
import io.github.torand.fastersql.projection.Projection;
21

22
import java.util.stream.Stream;
23

24
import static io.github.torand.fastersql.util.contract.Requires.requireNonBlank;
25
import static java.util.Objects.requireNonNull;
26

27
public class GenericConstant<T> implements Constant {
28
    private final T value;
29
    private final String alias;
30

31
    GenericConstant(T value, String alias) {
2✔
32
        this.value = requireNonNull(value, "Use NullConstant to represent 'null'");
5✔
33
        this.alias = alias;
3✔
34
    }
1✔
35

36
    // Sql
37

38
    @Override
39
    public String sql(Context context) {
40
        return "?";
2✔
41
    }
42

43
    @Override
44
    public Stream<Object> params(Context context) {
45
        return Stream.of(value);
4✔
46
    }
47

48
    // Projection
49

50
    @Override
51
    public Projection as(String alias) {
52
        requireNonBlank(alias, "No alias specified");
6✔
53
        return new GenericConstant(value, alias);
7✔
54
    }
55

56
    @Override
57
    public String alias() {
58
        return alias;
3✔
59
    }
60

61
    // Expression
62

63
    @Override
64
    public Stream<Field> fieldRefs() {
65
        return Stream.empty();
2✔
66
    }
67

68
    // Constant
69

70
    @Override
71
    public Object value() {
72
        return value;
×
73
    }
74

75
    @Override
76
    public Projection forField(Field field) {
77
        requireNonNull(field, "No field specified");
×
78
        return new GenericConstant(value, field.alias());
×
79
    }
80
}
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