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

torand / FasterSQL / 13591799490

28 Feb 2025 03:59PM UTC coverage: 65.237% (-1.3%) from 66.563%
13591799490

push

github

web-flow
Merge pull request #14 from torand/having-support

feat: supporting the HAVING clause + IS NULL operator now supports an…

214 of 408 branches covered (52.45%)

Branch coverage included in aggregate %.

273 of 389 new or added lines in 69 files covered. (70.18%)

3 existing lines in 3 files now uncovered.

1079 of 1574 relevant lines covered (68.55%)

3.68 hits per line

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

38.71
/src/main/java/io/github/torand/fastersql/util/contract/Requires.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.util.contract;
17

18
import io.github.torand.fastersql.util.collection.ArrayHelper;
19
import io.github.torand.fastersql.util.collection.CollectionHelper;
20

21
import java.util.Collection;
22
import java.util.Optional;
23

24
import static io.github.torand.fastersql.util.lang.StringHelper.nonBlank;
25
import static java.util.Objects.nonNull;
26
import static java.util.Objects.requireNonNull;
27

28
public final class Requires {
29

30
    private Requires() {}
31

32
    public static int[] requireNonEmpty(int[] array, String msg, Object... args) {
33
        requireNonNull(array, String.format(msg, args));
×
34
        require(() -> ArrayHelper.nonEmpty(array), msg, args);
×
35
        return array;
×
36
    }
37

38
    public static long[] requireNonEmpty(long[] array, String msg, Object... args) {
39
        requireNonNull(array, String.format(msg, args));
×
40
        require(() -> ArrayHelper.nonEmpty(array), msg, args);
×
41
        return array;
×
42
    }
43

44
    public static <T> T[] requireNonEmpty(T[] array, String msg, Object... args) {
45
        requireNonNull(array, String.format(msg, args));
6✔
46
        require(() -> ArrayHelper.nonEmpty(array), msg, args);
8✔
47
        return array;
2✔
48
    }
49

50
    public static <T extends Collection<?>> T requireNonEmpty(T collection, String msg, Object... args) {
51
        requireNonNull(collection, String.format(msg, args));
6✔
52
        require(() -> CollectionHelper.nonEmpty(collection), msg, args);
8✔
53
        return collection;
2✔
54
    }
55

56
    public static String requireNonBlank(String string, String msg, Object... args) {
57
        requireNonNull(string, String.format(msg, args));
6✔
58
        require(() -> nonBlank(string), msg, args);
8✔
59
        return string;
2✔
60
    }
61

62
    public static <T> Optional<T> requireNonEmpty(Optional<T> optional, String msg, Object... args) {
NEW
63
        require(() -> nonNull(optional) && optional.isPresent(), msg, args);
×
NEW
64
        return optional;
×
65
    }
66

67
    public static void require(Requirement requirement, String msg, Object... args) {
68
        if (!requirement.test()) {
3!
69
            throw new IllegalArgumentException(String.format(msg, args));
×
70
        }
71
    }
1✔
72

73
    public static void precondition(Requirement requirement, String msg, Object... args) {
74
        if (!requirement.test()) {
×
75
            throw new IllegalStateException(String.format(msg, args));
×
76
        }
77
    }
×
78
}
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