Skip to content

Commit 42daf05

Browse files
committed
1 parent 269db59 commit 42daf05

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright 2024 https://github.com/openapi-processor/openapi-processor-base
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.openapiprocessor.core.writer.java
27

38
import io.openapiprocessor.core.writer.SourceFormatter
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2025 https://github.com/openapi-processor/openapi-processor-base
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiprocessor.core.writer.java
7+
8+
import io.openapiprocessor.core.converter.ApiOptions
9+
import io.openapiprocessor.core.writer.SourceFormatter
10+
11+
class SourceFormatterFactory {
12+
13+
fun getFormatter(options: ApiOptions): SourceFormatter {
14+
return if (options.formatCode) {
15+
when (options.formatCodeFormatter) {
16+
"google" -> GoogleFormatter()
17+
"eclipse" -> EclipseFormatter()
18+
else -> GoogleFormatter()
19+
}
20+
} else {
21+
GoogleFormatter()
22+
}
23+
}
24+
}

openapi-processor-core/src/testInt/kotlin/io/openapiprocessor/core/TestProcessor.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,7 @@ class TestProcessor:
119119
}
120120

121121
private fun getFormatter(): SourceFormatter {
122-
return if (apiOptions.formatCode) {
123-
when (apiOptions.formatCodeFormatter) {
124-
"google" -> GoogleFormatter()
125-
"eclipse" -> EclipseFormatter()
126-
else -> GoogleFormatter()
127-
}
128-
} else {
129-
GoogleFormatter()
130-
}
122+
return SourceFormatterFactory().getFormatter(apiOptions)
131123
}
132124
}
133125

0 commit comments

Comments
 (0)