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

torand / jsonschema2java / 18399814123

10 Oct 2025 07:35AM UTC coverage: 78.214% (-0.9%) from 79.157%
18399814123

push

github

torand
fix: bean validation annotations on primitive subtypes of compound pojo property types now generated

287 of 413 branches covered (69.49%)

Branch coverage included in aggregate %.

440 of 533 new or added lines in 26 files covered. (82.55%)

1 existing line in 1 file now uncovered.

808 of 987 relevant lines covered (81.86%)

4.75 hits per line

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

66.67
/src/main/java/io/github/torand/jsonschema2java/utils/StringUtils.java
1
/*
2
 * Copyright (c) 2024-2025 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.jsonschema2java.utils;
17

18
import io.github.torand.javacommons.lang.StringHelper;
19

20
import java.util.List;
21
import java.util.Optional;
22
import java.util.stream.Stream;
23

24
import static io.github.torand.javacommons.collection.CollectionHelper.isEmpty;
25
import static io.github.torand.javacommons.lang.StringHelper.capitalize;
26
import static io.github.torand.javacommons.lang.StringHelper.isBlank;
27
import static java.util.stream.Collectors.joining;
28

29
/**
30
 * A collection of String utilities.
31
 */
32
public class StringUtils {
33
    private StringUtils() {}
34

35
    /**
36
     * Gets the plural suffix based on specified cardinality.
37
     * @param count the cardinality.
38
     * @return the plural suffix, or empty string if single count.
39
     */
40
    public static String pluralSuffix(int count) {
41
        return count == 1 ? "" : "s";
7✔
42
    }
43

44
    /**
45
     * Transforms specified string to pascal case.
46
     * @param value the string to modify.
47
     * @return the modified string.
48
     */
49
    public static String toPascalCase(String value) {
50
        Optional<String> delimiter = Stream.of(" ", "_", "-").filter(value::contains).findFirst();
23✔
51
        if (delimiter.isEmpty()) {
3✔
52
            return capitalize(value);
3✔
53
        }
54

55
        return Stream.of(value.split(delimiter.get()))
8✔
56
            .map(StringHelper::capitalize)
1✔
57
            .collect(joining());
3✔
58
    }
59

60
    /**
61
     * Returns specified string with line break characters removed.
62
     * @param value the string to modify.
63
     * @return the modified string.
64
     */
65
    public static String removeLineBreaks(String value) {
66
        if (isBlank(value)) {
×
67
            return value;
×
68
        }
NEW
69
        return value.replace("\n", " ");
×
70
    }
71

72
    /**
73
     * Returns specified values as a comma-delimited string.
74
     * @param values the values to join.
75
     * @return the joined values.
76
     */
77
    public static String joinCsv(List<String> values) {
78
        if (isEmpty(values)) {
3!
79
            return "";
×
80
        }
81

82
        return String.join(", ", values);
4✔
83
    }
84

85
    /**
86
     * Returns the class base name from specified fully qualified class name.
87
     * @param fqn the fully qualified class name.
88
     * @return the class base name.
89
     */
90
    public static String getClassNameFromFqn(String fqn) {
91
        int lastDot = fqn.lastIndexOf(".");
4✔
92
        if (lastDot == -1) {
3!
NEW
93
            throw new IllegalArgumentException("Unexpected fully qualified class name: %s".formatted(fqn));
×
94
        }
95
        return fqn.substring(lastDot+1);
6✔
96
    }
97
}
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