com.mercateo.jsonschema.schema.ObjectContext.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-schema Show documentation
Show all versions of json-schema Show documentation
json-schema generator for the JVM.
package com.mercateo.jsonschema.schema
import com.mercateo.jsonschema.property.Property
import java.util.*
data class ObjectContext(
val property: Property<*, T>,
val defaultValue: T? = null,
val allowedValues: Set = emptySet()
) {
val propertyDescriptor get() = property.propertyDescriptor
val reference get() = property.reference
fun createInner(child: Property, valueAccessor: (T) -> U?): ObjectContext {
@Suppress("UNCHECKED_CAST")
val allowedValues = allowedValues.map(valueAccessor).filter(
Objects::nonNull).toSet() as Set
val defaultValue = defaultValue?.let(valueAccessor)
return ObjectContext(child, defaultValue, allowedValues)
}
}