package org.jetbrains.dokka.plugability internal class LazyEvaluated private constructor(private val recipe: ((DokkaContext) -> T)? = null, private var value: T? = null) { internal fun get(context: DokkaContext): T { if(value == null) { value = recipe?.invoke(context) } return value ?: throw AssertionError("Incorrect initialized LazyEvaluated instance") } companion object { fun fromInstance(value: T) = LazyEvaluated(value = value) fun fromRecipe(recipe: (DokkaContext) -> T) = LazyEvaluated(recipe = recipe) } }