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

torand / FasterSQL / 12970556809

26 Jan 2025 02:19AM UTC coverage: 46.173% (-1.0%) from 47.188%
12970556809

push

github

torand
feat: support decimal number constants

108 of 332 branches covered (32.53%)

Branch coverage included in aggregate %.

1 of 29 new or added lines in 2 files covered. (3.45%)

1 existing line in 1 file now uncovered.

622 of 1249 relevant lines covered (49.8%)

2.63 hits per line

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

0.0
/src/main/java/io/github/torand/fastersql/constant/DecimalConstant.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 DecimalConstant implements Constant {
28
    private final Double value;
29
    private final String alias;
30

NEW
31
    DecimalConstant(Double value, String alias) {
×
NEW
32
        this.value = requireNonNull(value, "Use NullConstant to represent 'null'");
×
NEW
33
        this.alias = alias;
×
NEW
34
    }
×
35

36
    // Sql
37

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

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

48
    // Projection
49

50
    @Override
51
    public Projection as(String alias) {
NEW
52
        requireNonBlank(alias, "No alias specified");
×
NEW
53
        return new DecimalConstant(value, alias);
×
54
    }
55

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

61
    // Expression
62

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

68
    // Constant
69

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

75
    @Override
76
    public Projection forField(Field field) {
NEW
77
        requireNonNull(field, "No field specified");
×
NEW
78
        return new DecimalConstant(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