• 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

72.73
/src/main/java/io/github/torand/jsonschema2java/model/PojoInfo.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.model;
17

18
import io.github.torand.javacommons.collection.CollectionHelper;
19

20
import java.util.*;
21

22
import static java.util.Collections.emptyList;
23
import static java.util.Objects.nonNull;
24

25
/**
26
 * Describes a pojo.
27
 * @param name the class name.
28
 * @param modelSubdir the model subdirectory to place the pojo.
29
 * @param modelSubpackage the model subpackage of the pojo.
30
 * @param annotations the annotations decorating this pojo.
31
 * @param properties the properties of this pojo.
32
 * @param deprecationMessage the deprecation message, if any.
33
 */
34
public record PojoInfo (
21✔
35
    String name,
36
    String modelSubdir,
37
    String modelSubpackage,
38
    List<AnnotationInfo> annotations,
39
    List<PropertyInfo> properties,
40
    String deprecationMessage
41
) implements EntityInfo {
42

43
    /**
44
     * Constructs a {@link PojoInfo} object.
45
     * @param name the class name.
46
     */
47
    public PojoInfo(String name) {
48
        this(name, null, null, emptyList(), emptyList(), null);
8✔
49
    }
1✔
50

51
    /**
52
     * Returns a new {@link PojoInfo} object with specified model subdirectory.
53
     * @param modelSubdir the model subdirectory.
54
     * @return the new and updated {@link PojoInfo} object.
55
     */
56
    public PojoInfo withModelSubdir(String modelSubdir) {
57
        return new PojoInfo(name, modelSubdir, modelSubpackage, annotations, properties, deprecationMessage);
15✔
58
    }
59

60
    /**
61
     * Returns a new {@link PojoInfo} object with specified model subpackage.
62
     * @param modelSubpackage the model subpackage.
63
     * @return the new and updated {@link PojoInfo} object.
64
     */
65
    public PojoInfo withModelSubpackage(String modelSubpackage) {
66
        return new PojoInfo(name, modelSubpackage, modelSubpackage, annotations, properties, deprecationMessage);
14✔
67
    }
68

69
    /**
70
     * Returns a new {@link PojoInfo} object with specified annotation added.
71
     * @param annotation the annotation to add.
72
     * @return the new and updated {@link PojoInfo} object.
73
     */
74
    public PojoInfo withAddedAnnotation(AnnotationInfo annotation) {
75
        List<AnnotationInfo> newAnnotations = new LinkedList<>(annotations);
6✔
76
        newAnnotations.add(annotation);
4✔
77
        return new PojoInfo(name, modelSubpackage, modelSubpackage, newAnnotations, properties, deprecationMessage);
15✔
78
    }
79

80
    /**
81
     * Returns a new {@link PojoInfo} object with specified properties added.
82
     * @param properties the properties to add.
83
     * @return the new and updated {@link PojoInfo} object.
84
     */
85
    public PojoInfo withAddedProperties(Collection<PropertyInfo> properties) {
86
        List<PropertyInfo> newProperties = new LinkedList<>(this.properties);
6✔
87
        newProperties.addAll(properties);
4✔
88
        return new PojoInfo(name, modelSubpackage, modelSubpackage, annotations, newProperties, deprecationMessage);
15✔
89
    }
90

91
    /**
92
     * Returns a new {@link PojoInfo} object with specified deprecation message.
93
     * @param deprecationMessage the deprecation message.
94
     * @return the new and updated {@link PojoInfo} object.
95
     */
96
    public PojoInfo withDeprecationMessage(String deprecationMessage) {
NEW
97
        return new PojoInfo(name, modelSubpackage, modelSubpackage, annotations, properties, deprecationMessage);
×
98
    }
99

100
    /**
101
     * Gets whether pojo is deprecated.
102
     * @return true if pojo is deprecated; else false.
103
     */
104
    public boolean isDeprecated() {
105
        return nonNull(deprecationMessage);
4✔
106
    }
107

108
    /**
109
     * Gets whether pojo has no properties.
110
     * @return true if pojo has no properties; else false.
111
     */
112
    public boolean isEmpty() {
113
        return CollectionHelper.isEmpty(properties);
×
114
    }
115

116
    @Override
117
    public Set<String> aggregatedNormalImports() {
118
        Set<String> aggregated = new TreeSet<>();
4✔
119
        properties.stream().map(p -> p.aggregatedNormalImports()).forEach(aggregated::addAll);
14✔
120
        annotations.stream().map(a -> a.imports().normalImports()).forEach(aggregated::addAll);
15✔
121
        return aggregated;
2✔
122
    }
123

124
    @Override
125
    public Set<String> aggregatedStaticImports() {
NEW
126
        Set<String> aggregated = new TreeSet<>();
×
NEW
127
        properties.stream().map(p -> p.aggregatedStaticImports()).forEach(aggregated::addAll);
×
NEW
128
        annotations.stream().map(a -> a.imports().staticImports()).forEach(aggregated::addAll);
×
NEW
129
        return aggregated;
×
130
    }
131
}
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