File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
gradle-plugin/plugin/src/main/java/com/yelp/codegen/utils Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import io.swagger.codegen.CodegenModel
2+ import io.swagger.codegen.CodegenProperty
3+
4+ internal enum class CodegenModelVar {
5+ ALL_VARS ,
6+ OPTIONAL_VARS ,
7+ PARENT_VARS ,
8+ READ_ONLY_VARS ,
9+ READ_WRITE_VARS ,
10+ REQUIRED_VARS ,
11+ VARS ;
12+
13+ companion object {
14+ /* *
15+ * Allow the execution of an action on all the var attributes
16+ */
17+ fun forEachVarAttribute (
18+ codegenModel : CodegenModel ,
19+ action : (CodegenModelVar , MutableList <CodegenProperty >) -> Unit
20+ ) {
21+ values().forEach {
22+ action(it, it.value(codegenModel))
23+ }
24+ }
25+ }
26+
27+ internal fun value (codegenModel : CodegenModel ): MutableList <CodegenProperty > {
28+ return when (this ) {
29+ ALL_VARS -> codegenModel.allVars
30+ OPTIONAL_VARS -> codegenModel.optionalVars
31+ PARENT_VARS -> codegenModel.parentVars
32+ READ_ONLY_VARS -> codegenModel.readOnlyVars
33+ READ_WRITE_VARS -> codegenModel.readWriteVars
34+ REQUIRED_VARS -> codegenModel.requiredVars
35+ VARS -> codegenModel.vars
36+ }
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments