Skip to content

Commit 35df36f

Browse files
committed
simpler
1 parent 129c2c6 commit 35df36f

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/writer/java/BeanValidationFactory.kt

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -177,29 +177,16 @@ open class BeanValidationFactory(
177177
}
178178

179179
private fun DataType.shouldHaveValid(options: ApiOptions): Boolean {
180-
return if (this is SingleDataType && options.beanValidationValidOnReactive)
181-
true
182-
183-
else if (this is ModelDataType)
184-
true
185-
186-
else if (this is ArrayDataType)
187-
item is ModelDataType
188-
189-
else if (this is InterfaceDataType)
190-
true
191-
192-
else if (this is MappedCollectionDataType && options.beanValidationValidOnReactive)
193-
multi
194-
195-
else if (this is MappedCollectionDataType)
196-
false
197-
198-
else if (this is SourceDataType)
199-
sourceDataType?.shouldHaveValid(options) ?: false
200-
201-
else
202-
false
180+
return when {
181+
this is SingleDataType && options.beanValidationValidOnReactive -> true
182+
this is ModelDataType -> true
183+
this is ArrayDataType -> item is ModelDataType
184+
this is InterfaceDataType -> true
185+
this is MappedCollectionDataType && options.beanValidationValidOnReactive -> multi
186+
this is MappedCollectionDataType -> false
187+
this is SourceDataType -> sourceDataType?.shouldHaveValid(options) ?: false
188+
else -> false
189+
}
203190
}
204191

205192
private fun DataType.isString(): Boolean = this is StringDataType

0 commit comments

Comments
 (0)