All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codeblessing.sourceamazing.builder.api.BuilderApi.kt Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package org.codeblessing.sourceamazing.builder.api

import org.codeblessing.sourceamazing.schema.api.SchemaContext
import java.util.*
import kotlin.reflect.KClass

object BuilderApi {

    fun  withBuilder(schemaContext: SchemaContext, inputDefinitionClass: KClass, builderUsage: (builder: I) -> Unit) {
        val builderProcessorApis: ServiceLoader = ServiceLoader.load(BuilderProcessorApi::class.java)

        val builderProcessorApi = requireNotNull(builderProcessorApis.firstOrNull()) {
            "Could not find an implementation of the interface '${BuilderProcessorApi::class}'."
        }
        builderProcessorApi.withBuilder(schemaContext, inputDefinitionClass, builderUsage)
    }
}