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

torand / FasterSQL / 12969157631

25 Jan 2025 11:02PM UTC coverage: 49.458% (-1.4%) from 50.829%
12969157631

push

github

torand
feat: introduced the concept of expressions

108 of 322 branches covered (33.54%)

Branch coverage included in aggregate %.

97 of 271 new or added lines in 43 files covered. (35.79%)

622 of 1154 relevant lines covered (53.9%)

2.85 hits per line

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

26.09
/src/main/java/io/github/torand/fastersql/constant/Constants.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 java.util.UUID;
19

20
import static java.util.Objects.isNull;
21

22
public final class Constants {
23

24
    private Constants() {}
25

26
    public static Constant constant(Object value) {
27
        if (isNull(value)) {
3!
NEW
28
            return nullValue();
×
29
        } else if (value instanceof String string) {
6!
30
            return constant(string);
3✔
NEW
31
        } else if (value instanceof Integer integer) {
×
NEW
32
            return constant(Long.valueOf(integer));
×
NEW
33
        } else if (value instanceof Long longValue) {
×
NEW
34
            return constant(longValue);
×
NEW
35
        } else if (value instanceof UUID uuid) {
×
NEW
36
            return constant(uuid);
×
NEW
37
        } else if (value instanceof Enum enumValue) {
×
NEW
38
            return constant(enumValue);
×
39
        }
40

NEW
41
        throw new IllegalArgumentException("Unsupported constant type: " + value.getClass());
×
42
    }
43

44
    public static Constant constant(UUID value) {
NEW
45
        if (isNull(value)) {
×
NEW
46
            return nullValue();
×
47
        }
NEW
48
        return new StringConstant(value.toString(), null);
×
49
    }
50

51
    public static Constant constant(Enum<? extends Enum<?>> value) {
NEW
52
        if (isNull(value)) {
×
NEW
53
            return nullValue();
×
54
        }
NEW
55
        return new StringConstant(value.name(), null);
×
56
    }
57

58
    public static Constant constant(String value) {
59
        if (isNull(value)) {
3!
NEW
60
            return nullValue();
×
61
        }
62
        return new StringConstant(value, null);
6✔
63
    }
64

65
    public static Constant constant(Long value) {
66
        if (isNull(value)) {
3!
NEW
67
            return nullValue();
×
68
        }
69
        return new IntegerConstant(value, null);
6✔
70
    }
71

72
    public static Constant nullValue() {
73
        return new NullConstant(null);
5✔
74
    }
75
}
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