This repository was archived by the owner on Mar 16, 2025. It is now read-only.
File tree 2 files changed +19
-16
lines changed
src/main/kotlin/io/openapiprocessor/core/writer/java
2 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ open class BeanValidationFactory {
15
15
16
16
fun validate (dataType : DataType , required : Boolean = false): BeanValidationInfo {
17
17
return BeanValidationInfo (
18
- annotateGenericItem( dataType) ,
18
+ dataType,
19
19
collectImports(dataType, required),
20
20
collectAnnotations(dataType, required)
21
21
)
@@ -81,13 +81,6 @@ open class BeanValidationFactory {
81
81
return annotations
82
82
}
83
83
84
- private fun annotateGenericItem (dataType : DataType ): String {
85
- if (! dataType.isCollectionOfModel())
86
- return dataType.getName()
87
-
88
- return (dataType as MappedCollectionDataType ).getName(BeanValidation .VALID .annotation)
89
- }
90
-
91
84
private fun requiresValidImport (dataType : DataType ): Boolean {
92
85
if (dataType.isModel())
93
86
return true
@@ -156,13 +149,6 @@ private fun DataType.isArrayOfModel(): Boolean {
156
149
return item.isModel()
157
150
}
158
151
159
- private fun DataType.isCollectionOfModel (): Boolean {
160
- if (this !is MappedCollectionDataType )
161
- return false
162
-
163
- return item.isModel()
164
- }
165
-
166
152
private fun DataType.isString (): Boolean = this is StringDataType
167
153
168
154
private fun DataType.isCollection (): Boolean =
Original file line number Diff line number Diff line change 5
5
6
6
package io.openapiprocessor.core.writer.java
7
7
8
+ import io.openapiprocessor.core.model.datatypes.DataType
9
+ import io.openapiprocessor.core.model.datatypes.MappedCollectionDataType
10
+ import io.openapiprocessor.core.model.datatypes.ModelDataType
11
+
8
12
class BeanValidationInfo (
9
- val typeName : String ,
13
+ val dataType : DataType ,
10
14
val imports : Set <String >,
11
15
val annotations : List <String >
12
16
) {
17
+ val typeName: String
18
+ get() {
19
+ // no collection or array
20
+ if (dataType !is MappedCollectionDataType )
21
+ return dataType.getTypeName()
22
+
23
+ if (dataType.item !is ModelDataType )
24
+ return dataType.getTypeName()
25
+
26
+ return dataType.getTypeNameWithAnnotatedItem(BeanValidation .VALID .annotation)
27
+ }
28
+
13
29
val hasAnnotations
14
30
get() = annotations.isNotEmpty()
31
+
15
32
}
You can’t perform that action at this time.
0 commit comments