Skip to content

Commit 67bcb73

Browse files
committed
Add reified OptionAggregateBuilderContainer#inlineClassAggregate
1 parent 3b29be1 commit 67bcb73

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main/kotlin/io/github/freya022/botcommands/api/core/options/builder/OptionAggregateBuilderContainer.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ interface OptionAggregateBuilderContainer<T : OptionAggregateBuilder<T>> {
2222
fun aggregate(declaredName: String, aggregator: KFunction<*>, block: T.() -> Unit = {})
2323
}
2424

25+
/**
26+
* Declares an aggregate creating an instance of the specified [inline class][clazz],
27+
* which can only accept a single option.
28+
*
29+
* @param declaredName Name of the declared parameter which receives the value class
30+
* @param clazz The inline class type
31+
*/
2532
fun <T : OptionAggregateBuilder<T>> OptionAggregateBuilderContainer<T>.inlineClassAggregate(
2633
declaredName: String,
2734
clazz: KClass<*>,
@@ -34,4 +41,18 @@ fun <T : OptionAggregateBuilder<T>> OptionAggregateBuilderContainer<T>.inlineCla
3441
?: throwArgument(aggregatorConstructor, "Constructor must only have one parameter")
3542
block(parameterName)
3643
}
44+
}
45+
46+
/**
47+
* Declares an aggregate creating an instance of the specified [inline class][T],
48+
* which can only accept a single option.
49+
*
50+
* @param T The inline class type
51+
* @param declaredName Name of the declared parameter which receives the value class
52+
*/
53+
inline fun <reified T : OptionAggregateBuilder<T>> OptionAggregateBuilderContainer<T>.inlineClassAggregate(
54+
declaredName: String,
55+
noinline block: T.(valueName: String) -> Unit = {},
56+
) {
57+
return inlineClassAggregate(declaredName, T::class, block)
3758
}

0 commit comments

Comments
 (0)