• 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

81.25
/src/main/java/io/github/torand/jsonschema2java/model/PropertyInfo.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 java.util.LinkedList;
19
import java.util.List;
20
import java.util.Set;
21
import java.util.TreeSet;
22

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

26
/**
27
 * Describes a property.
28
 * @param name the property names.
29
 * @param type the property type.
30
 * @param required the required flag.
31
 * @param annotations the annotations decorating this pojo.
32
 * @param deprecationMessage the deprecation message, if any.
33
 */
34
public record PropertyInfo (
18✔
35
    String name,
36
    TypeInfo type,
37
    boolean required,
38
    List<AnnotationInfo> annotations,
39
    String deprecationMessage
40
) implements EntityInfo {
41

42
    /**
43
     * Constructs a {@link PropertyInfo} object.
44
     * @param name the property name.
45
     */
46
    public PropertyInfo(String name) {
47
        this(name, null, false, emptyList(), null);
7✔
48
    }
1✔
49

50
    /**
51
     * Returns a new {@link PropertyInfo} object with specified type.
52
     * @param type the property type.
53
     * @return the new and updated {@link PropertyInfo} object.
54
     */
55
    public PropertyInfo withType(TypeInfo type) {
56
        return new PropertyInfo(name, type, required, annotations, deprecationMessage);
13✔
57
    }
58

59
    /**
60
     * Returns a new {@link PropertyInfo} object with specified required flag.
61
     * @param required the required flag.
62
     * @return the new and updated {@link PropertyInfo} object.
63
     */
64
    public PropertyInfo withRequired(boolean required) {
65
        return new PropertyInfo(name, type, required, annotations, deprecationMessage);
13✔
66
    }
67

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

79
    /**
80
     * Returns a new {@link PropertyInfo} object with specified deprecation message.
81
     * @param deprecationMessage the deprecation message.
82
     * @return the new and updated {@link PropertyInfo} object.
83
     */
84
    public PropertyInfo withDeprecationMessage(String deprecationMessage) {
85
        return new PropertyInfo(name, type, required, annotations, deprecationMessage);
13✔
86
    }
87

88
    /**
89
     * Gets whether property is deprecated.
90
     * @return true if property is deprecated; else false.
91
     */
92
    public boolean isDeprecated() {
93
        return nonNull(deprecationMessage);
4✔
94
    }
95

96
    @Override
97
    public Set<String> aggregatedNormalImports() {
98
        Set<String> aggregated = new TreeSet<>(type.aggregatedNormalImports());
7✔
99
        annotations.stream().map(a -> a.imports().normalImports()).forEach(aggregated::addAll);
15✔
100
        return aggregated;
2✔
101
    }
102

103
    @Override
104
    public Set<String> aggregatedStaticImports() {
NEW
105
        Set<String> aggregated = new TreeSet<>(type.aggregatedStaticImports());
×
NEW
106
        annotations.stream().map(a -> a.imports().staticImports()).forEach(aggregated::addAll);
×
NEW
107
        return aggregated;
×
108
    }
109
}
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