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

jvmMain.definitions.RaptorEnumGraphDefinitionBuilder.kt Maven / Gradle / Ivy

The newest version!
package io.fluidsonic.raptor

import io.fluidsonic.raptor.graphql.internal.*


// TODO customize value definitions
@RaptorDsl
public class RaptorEnumGraphDefinitionBuilder> internal constructor(
	kotlinType: KotlinType,
	name: String,
	private val stackTrace: List,
	private val values: Collection,
) :
	RaptorNamedGraphTypeDefinitionBuilder(
		kotlinType = kotlinType,
		name = name
	) {


	override fun build(description: String?) =
		EnumGraphDefinition(
			additionalDefinitions = emptyList(),
			description = description,
			isInput = true,
			isOutput = true,
			kotlinType = kotlinType,
			name = name,
			parse = { name ->
				[email protected] { it.name == name }
					?: invalid(details = "valid values: ${[email protected] { it.name }.joinToString(separator = ", ") { it.name }}")
			}, // TODO leak. rework
			serialize = {
				@Suppress("UNCHECKED_CAST")
				(it as Type).name
			}, // TODO rework
			stackTrace = stackTrace,
			values = values.mapTo(hashSetOf()) { it.name }
		)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy