Skip to content

Commit

Permalink
extract default SchemaClient extraction into static factory method, r…
Browse files Browse the repository at this point in the history
…ename DefaultSchemaClient to URLQueryingSchemaClient
  • Loading branch information
erosb committed Oct 30, 2024
1 parent 9061adf commit 37ae35b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 11 additions & 1 deletion src/main/kotlin/com/github/erosb/jsonsKema/SchemaClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import java.nio.charset.StandardCharsets
import java.util.*

fun interface SchemaClient {

companion object {
@JvmStatic
fun createDefaultInstance(additionalMappings: Map<URI, String>): SchemaClient = MemoizingSchemaClient(
PrepopulatedSchemaClient(
ClassPathAwareSchemaClient(URLQueryingSchemaClient()),
additionalMappings
)
)
}
fun get(uri: URI): InputStream

/**
Expand All @@ -30,7 +40,7 @@ fun interface SchemaClient {
}
}

internal class DefaultSchemaClient : SchemaClient {
internal class URLQueryingSchemaClient : SchemaClient {

override fun get(uri: URI): InputStream {
try {
Expand Down
7 changes: 1 addition & 6 deletions src/main/kotlin/com/github/erosb/jsonsKema/SchemaLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ data class SchemaLoaderConfig @JvmOverloads constructor(
companion object {
@JvmStatic
fun createDefaultConfig(additionalMappings: Map<URI, String> = mapOf()) = SchemaLoaderConfig(
schemaClient = MemoizingSchemaClient(
PrepopulatedSchemaClient(
ClassPathAwareSchemaClient(DefaultSchemaClient()),
additionalMappings
)
),
schemaClient = SchemaClient.createDefaultInstance(additionalMappings),
additionalMappings = additionalMappings
)
}
Expand Down

0 comments on commit 37ae35b

Please sign in to comment.