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

coditory / quark-uri / #3

pending completion
#3

push

github-actions

ogesaku
init

1212 of 1212 new or added lines in 21 files covered. (100.0%)

926 of 1212 relevant lines covered (76.4%)

0.76 hits per line

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

28.57
/src/main/java/com/coditory/quark/uri/Preconditions.java
1
package com.coditory.quark.uri;
2

3
import org.jetbrains.annotations.Nullable;
4

5
import java.util.Objects;
6

7
final class Preconditions {
8
    private Preconditions() {
×
9
        throw new UnsupportedOperationException("Do not instantiate utility class");
×
10
    }
11

12
    static void expect(boolean check, String message, Object... args) {
13
        if (!check) {
×
14
            throw new IllegalArgumentException(String.format(message, args));
×
15
        }
16
    }
×
17

18
    static <T> T expectNonNull(@Nullable T value, String name) {
19
        if (value == null) {
1✔
20
            String message = message("Expected non-null value", name);
×
21
            throw new IllegalArgumentException(message);
×
22
        }
23
        return value;
1✔
24
    }
25

26
    static String expectNonEmpty(@Nullable String value, String name) {
27
        if (value == null || value.isEmpty()) {
1✔
28
            String message = message("Expected non-null and non-empty value", name, value);
×
29
            throw new IllegalArgumentException(message);
×
30
        }
31
        return value;
1✔
32
    }
33

34
    static String expectNonBlank(@Nullable String value, String name) {
35
        if (value == null || value.isBlank()) {
1✔
36
            String message = message("Expected non-null and non-blank value", name, value);
×
37
            throw new IllegalArgumentException(message);
×
38
        }
39
        return value;
1✔
40
    }
41

42
    static String expectNoWhitespaces(@Nullable String value, String name) {
43
        if (value == null || Strings.containsWhitespace(value)) {
1✔
44
            String message = message("Expected non-null value with no whitespaces", name, value);
×
45
            throw new IllegalArgumentException(message);
×
46
        }
47
        return value;
1✔
48
    }
49

50
    private static String message(String expectation, String fieldName, Object value) {
51
        String field = fieldName != null ? (": " + fieldName) : "";
×
52
        String stringValue = value instanceof String
×
53
                ? ("\"" + value + "\"")
×
54
                : Objects.toString(value);
×
55
        return expectation + field + ". Got: " + stringValue;
×
56
    }
57

58
    private static String message(String expectation, String fieldName) {
59
        String field = fieldName != null ? (": " + fieldName) : "";
×
60
        return expectation + field;
×
61
    }
62
}
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

© 2025 Coveralls, Inc