Skip to content

Commit

Permalink
Add reified OptionAggregateBuilderContainer#inlineClassAggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
freya022 committed Sep 30, 2024
1 parent 3b29be1 commit 67bcb73
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ interface OptionAggregateBuilderContainer<T : OptionAggregateBuilder<T>> {
fun aggregate(declaredName: String, aggregator: KFunction<*>, block: T.() -> Unit = {})
}

/**
* Declares an aggregate creating an instance of the specified [inline class][clazz],
* which can only accept a single option.
*
* @param declaredName Name of the declared parameter which receives the value class
* @param clazz The inline class type
*/
fun <T : OptionAggregateBuilder<T>> OptionAggregateBuilderContainer<T>.inlineClassAggregate(
declaredName: String,
clazz: KClass<*>,
Expand All @@ -34,4 +41,18 @@ fun <T : OptionAggregateBuilder<T>> OptionAggregateBuilderContainer<T>.inlineCla
?: throwArgument(aggregatorConstructor, "Constructor must only have one parameter")
block(parameterName)
}
}

/**
* Declares an aggregate creating an instance of the specified [inline class][T],
* which can only accept a single option.
*
* @param T The inline class type
* @param declaredName Name of the declared parameter which receives the value class
*/
inline fun <reified T : OptionAggregateBuilder<T>> OptionAggregateBuilderContainer<T>.inlineClassAggregate(
declaredName: String,
noinline block: T.(valueName: String) -> Unit = {},
) {
return inlineClassAggregate(declaredName, T::class, block)
}

0 comments on commit 67bcb73

Please sign in to comment.