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

torand / openapi2java / 18307112888

07 Oct 2025 08:43AM UTC coverage: 82.278% (+0.1%) from 82.132%
18307112888

push

github

torand
fix: bean validation annotations on subtypes of compound pojo property and resource method parameter types now generated

537 of 763 branches covered (70.38%)

Branch coverage included in aggregate %.

50 of 56 new or added lines in 8 files covered. (89.29%)

6 existing lines in 2 files now uncovered.

1594 of 1827 relevant lines covered (87.25%)

5.12 hits per line

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

75.0
/src/main/java/io/github/torand/openapi2java/model/MethodParamInfo.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.openapi2java.model;
17

18
import java.util.*;
19

20
import static java.util.Collections.emptyList;
21
import static java.util.Objects.nonNull;
22

23
/**
24
 * Describes a method parameter.
25
 * @param name the parameter name.
26
 * @param imports the imports required by the parameter.
27
 * @param annotations the annotations decorating this parameter.
28
 * @param type the parameter type.
29
 * @param comment the parameter comment text, if any.
30
 * @param nullable the nullable flag.
31
 * @param deprecationMessage the deprecation message, if any.
32
 */
33
public record MethodParamInfo (
24✔
34
    String name,
35
    ImportInfo imports,
36
    List<AnnotationInfo> annotations,
37
    TypeInfo type,
38
    String comment,
39
    boolean nullable,
40
    String deprecationMessage
41
) implements EntityInfo, ImportsSupplier {
42

43
    /**
44
     * Constructs a {@link MethodParamInfo} object.
45
     */
46
    public MethodParamInfo() {
47
        this(null, ImportInfo.empty(), emptyList(), null, null, false, null);
9✔
48
    }
1✔
49

50
    /**
51
     * Constructs a {@link MethodParamInfo} object.
52
     * @param name the parameter name.
53
     */
54
    public MethodParamInfo(String name) {
55
        this(name, ImportInfo.empty(), emptyList(), null, null, false, null);
9✔
56
    }
1✔
57

58
    /**
59
     * Returns a new {@link MethodParamInfo} object with specified name.
60
     * @param name the name.
61
     * @return the new and updated {@link MethodParamInfo} object.
62
     */
63
    public MethodParamInfo withName(String name) {
64
        return new MethodParamInfo(name, imports, annotations, type, comment, nullable, deprecationMessage);
17✔
65
    }
66

67
    /**
68
     * Returns a new {@link MethodParamInfo} object with specified type.
69
     * @param type the name.
70
     * @return the new and updated {@link MethodParamInfo} object.
71
     */
72
    public MethodParamInfo withType(TypeInfo type) {
73
        return new MethodParamInfo(name, imports, annotations, type, comment, nullable, deprecationMessage);
17✔
74
    }
75

76
    /**
77
     * Returns a new {@link MethodParamInfo} object with specified comment.
78
     * @param comment the comment.
79
     * @return the new and updated {@link MethodParamInfo} object.
80
     */
81
    public MethodParamInfo withComment(String comment) {
82
        return new MethodParamInfo(name, imports, annotations, type, comment, nullable, deprecationMessage);
17✔
83
    }
84

85
    /**
86
     * Returns a new {@link MethodParamInfo} object with specified nullable flag.
87
     * @param nullable the nullable flag.
88
     * @return the new and updated {@link MethodParamInfo} object.
89
     */
90
    public MethodParamInfo withNullable(boolean nullable) {
91
        return new MethodParamInfo(name, imports, annotations, type, comment, nullable, deprecationMessage);
17✔
92
    }
93

94
    /**
95
     * Returns a new {@link MethodParamInfo} object with specified deprecation message.
96
     * @param deprecationMessage the deprecation message.
97
     * @return the new and updated {@link MethodParamInfo} object.
98
     */
99
    public MethodParamInfo withDeprecationMessage(String deprecationMessage) {
100
        return new MethodParamInfo(name, imports, annotations, type, comment, nullable, deprecationMessage);
×
101
    }
102

103
    /**
104
     * Returns a new {@link MethodParamInfo} object with specified imports added.
105
     * @param importsSupplier the imports to add.
106
     * @return the new and updated {@link MethodParamInfo} object.
107
     */
108
    public MethodParamInfo withAddedImports(ImportsSupplier importsSupplier) {
109
        return new MethodParamInfo(name, imports.withAddedImports(importsSupplier), annotations, type, comment, nullable, deprecationMessage);
20✔
110
    }
111

112
    /**
113
     * Returns a new {@link MethodParamInfo} object with specified annotation added.
114
     * @param annotation the annotation to add.
115
     * @return the new and updated {@link MethodParamInfo} object.
116
     */
117
    public MethodParamInfo withAddedAnnotation(AnnotationInfo annotation) {
118
        List<AnnotationInfo> newAnnotations = new LinkedList<>(this.annotations);
6✔
119
        newAnnotations.add(annotation);
4✔
120
        return new MethodParamInfo(name, imports, newAnnotations, type, comment, nullable, deprecationMessage);
17✔
121
    }
122

123
    /**
124
     * Returns a new {@link MethodParamInfo} object with specified annotations added.
125
     * @param annotations the annotations to add.
126
     * @return the new and updated {@link MethodParamInfo} object.
127
     */
128
    public MethodParamInfo withAddedAnnotations(Collection<AnnotationInfo> annotations) {
UNCOV
129
        MethodParamInfo merged = this;
×
UNCOV
130
        for (AnnotationInfo annotation : annotations) {
×
UNCOV
131
            merged = merged.withAddedAnnotation(annotation);
×
UNCOV
132
        }
×
UNCOV
133
        return merged;
×
134
    }
135

136
    /**
137
     * Gets whether parameter is nullable.
138
     * @return true if parameter is nullable; else false.
139
     */
140
    public boolean isDeprecated() {
141
        return nonNull(deprecationMessage);
4✔
142
    }
143

144
    @Override
145
    public Set<String> aggregatedNormalImports() {
146
        Set<String> aggregated = new TreeSet<>();
4✔
147
        aggregated.addAll(imports.normalImports());
6✔
148
        annotations.stream().map(a -> a.imports().normalImports()).forEach(aggregated::addAll);
15✔
149
        aggregated.addAll(type.aggregatedNormalImports());
6✔
150
        return aggregated;
2✔
151
    }
152

153
    @Override
154
    public Set<String> aggregatedStaticImports() {
155
        Set<String> aggregated = new TreeSet<>();
4✔
156
        aggregated.addAll(imports.staticImports());
6✔
157
        annotations.stream().map(a -> a.imports().staticImports()).forEach(aggregated::addAll);
15✔
158
        aggregated.addAll(type.aggregatedStaticImports());
6✔
159
        return aggregated;
2✔
160
    }
161
}
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