-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathCodegenModelVar.kt
More file actions
40 lines (36 loc) · 1.13 KB
/
CodegenModelVar.kt
File metadata and controls
40 lines (36 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.yelp.codegen.utils
import io.swagger.codegen.CodegenModel
import io.swagger.codegen.CodegenProperty
internal enum class CodegenModelVar {
ALL_VARS,
OPTIONAL_VARS,
PARENT_VARS,
READ_ONLY_VARS,
READ_WRITE_VARS,
REQUIRED_VARS,
VARS;
companion object {
/**
* Allow the execution of an action on all the var attributes
*/
fun forEachVarAttribute(
codegenModel: CodegenModel,
action: (CodegenModelVar, MutableList<CodegenProperty>) -> Unit
) {
values().forEach {
action(it, it.value(codegenModel))
}
}
}
internal fun value(codegenModel: CodegenModel): MutableList<CodegenProperty> {
return when (this) {
ALL_VARS -> codegenModel.allVars
OPTIONAL_VARS -> codegenModel.optionalVars
PARENT_VARS -> codegenModel.parentVars
READ_ONLY_VARS -> codegenModel.readOnlyVars
READ_WRITE_VARS -> codegenModel.readWriteVars
REQUIRED_VARS -> codegenModel.requiredVars
VARS -> codegenModel.vars
}
}
}