Skip to content

Commit

Permalink
File and URL names are used in JDK / suggested in IDE auto-import. Re…
Browse files Browse the repository at this point in the history
…name to avoid it
  • Loading branch information
koperagen committed Jun 5, 2024
1 parent 2c4fdfc commit 6dac9cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public sealed interface SupportedFormat {
public sealed interface SupportedFormatSample {

@JvmInline
public value class File(public val sampleFile: java.io.File) : SupportedFormatSample
public value class DataFile(public val sampleFile: File) : SupportedFormatSample

@JvmInline
public value class URL(public val sampleUrl: java.net.URL) : SupportedFormatSample
public value class DataUrl(public val sampleUrl: URL) : SupportedFormatSample

@JvmInline
public value class PathString(public val samplePath: String) : SupportedFormatSample
Expand Down Expand Up @@ -138,13 +138,13 @@ internal fun guessFormatForExtension(
internal fun guessFormat(
file: File,
formats: List<SupportedFormat> = supportedFormats,
sample: SupportedFormatSample.File? = SupportedFormatSample.File(file),
sample: SupportedFormatSample.DataFile? = SupportedFormatSample.DataFile(file),
): SupportedFormat? = guessFormatForExtension(file.extension.lowercase(), formats, sample = sample)

internal fun guessFormat(
url: URL,
formats: List<SupportedFormat> = supportedFormats,
sample: SupportedFormatSample.URL? = SupportedFormatSample.URL(url),
sample: SupportedFormatSample.DataUrl? = SupportedFormatSample.DataUrl(url),
): SupportedFormat? = guessFormatForExtension(url.path.substringAfterLast("."), formats, sample = sample)

internal fun guessFormat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public sealed interface SupportedFormat {
public sealed interface SupportedFormatSample {

@JvmInline
public value class File(public val sampleFile: java.io.File) : SupportedFormatSample
public value class DataFile(public val sampleFile: File) : SupportedFormatSample

@JvmInline
public value class URL(public val sampleUrl: java.net.URL) : SupportedFormatSample
public value class DataUrl(public val sampleUrl: URL) : SupportedFormatSample

@JvmInline
public value class PathString(public val samplePath: String) : SupportedFormatSample
Expand Down Expand Up @@ -138,13 +138,13 @@ internal fun guessFormatForExtension(
internal fun guessFormat(
file: File,
formats: List<SupportedFormat> = supportedFormats,
sample: SupportedFormatSample.File? = SupportedFormatSample.File(file),
sample: SupportedFormatSample.DataFile? = SupportedFormatSample.DataFile(file),
): SupportedFormat? = guessFormatForExtension(file.extension.lowercase(), formats, sample = sample)

internal fun guessFormat(
url: URL,
formats: List<SupportedFormat> = supportedFormats,
sample: SupportedFormatSample.URL? = SupportedFormatSample.URL(url),
sample: SupportedFormatSample.DataUrl? = SupportedFormatSample.DataUrl(url),
): SupportedFormat? = guessFormatForExtension(url.path.substringAfterLast("."), formats, sample = sample)

internal fun guessFormat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public class OpenApi : SupportedCodeGenerationFormat {
override fun acceptsSample(sample: SupportedFormatSample): Boolean = try {
when (sample) {
is SupportedFormatSample.DataString -> isOpenApiStr(sample.sampleData)
is SupportedFormatSample.File -> isOpenApi(sample.sampleFile)
is SupportedFormatSample.DataFile -> isOpenApi(sample.sampleFile)
is SupportedFormatSample.PathString -> isOpenApi(sample.samplePath)
is SupportedFormatSample.URL -> isOpenApi(sample.sampleUrl)
is SupportedFormatSample.DataUrl -> isOpenApi(sample.sampleUrl)
}
} catch (_: Exception) {
false
Expand Down

0 comments on commit 6dac9cd

Please sign in to comment.