@@ -6,24 +6,24 @@ import kotlin.properties.ReadOnlyProperty
66
77@Suppress(" UNCHECKED_CAST" )
88@InternalMokkeryApi
9- public abstract class MokkeryOptionsContainer : Iterable <MokkeryOption <Any ? >> {
9+ public abstract class MokkeryOptionsContainer : Iterable <MokkeryOption <Any >> {
1010
11- private val _options = mutableMapOf<String , MokkeryOption <Any ? >>()
11+ private val _options = mutableMapOf<String , MokkeryOption <Any >>()
1212 private val _containers = mutableListOf<MokkeryOptionsContainer >()
1313
1414
15- public override operator fun iterator (): Iterator <MokkeryOption <Any ? >> = _options
15+ public override operator fun iterator (): Iterator <MokkeryOption <Any >> = _options
1616 .values
1717 .asSequence()
1818 .plus(_containers .flatten())
1919 .iterator()
2020
21- public operator fun get (name : String ): MokkeryOption <Any ? >? {
21+ public operator fun get (name : String ): MokkeryOption <Any >? {
2222 return _options [name] ? : _containers .firstNotNullOfOrNull { it[name] }
2323 }
2424
2525 public operator fun plusAssign (option : MokkeryOption <* >) {
26- _options + = (option.name to option as MokkeryOption <Any ? >)
26+ _options + = (option.name to option as MokkeryOption <Any >)
2727 }
2828
2929 public operator fun plusAssign (container : MokkeryOptionsContainer ) {
@@ -34,24 +34,25 @@ public abstract class MokkeryOptionsContainer: Iterable<MokkeryOption<Any?>> {
3434}
3535
3636
37- internal interface MokkeryNamespace {
37+ @InternalMokkeryApi
38+ public interface MokkeryOptionsNamespace {
3839
39- val name: String
40- fun createName (name : String ): String
40+ public val name: String
41+ public fun createName (name : String ): String
4142
42- companion object {
43+ public companion object {
4344
44- val root = object : MokkeryNamespace {
45+ public val root: MokkeryOptionsNamespace = object : MokkeryOptionsNamespace {
4546
4647 override val name: String = " "
4748
4849 override fun createName (name : String ): String = name
4950 }
5051
51- val named: PropertyDelegateProvider <Any ?, ReadOnlyProperty <Any ?, MokkeryNamespace >>
52+ public val named: PropertyDelegateProvider <Any ?, ReadOnlyProperty <Any ?, MokkeryOptionsNamespace >>
5253 get() = PropertyDelegateProvider { _, it ->
5354 ReadOnlyProperty { _, _ ->
54- object : MokkeryNamespace {
55+ object : MokkeryOptionsNamespace {
5556 override val name: String = it.name
5657 override fun createName (name : String ): String = " ${this .name} .$name "
5758 }
@@ -60,23 +61,24 @@ internal interface MokkeryNamespace {
6061 }
6162}
6263
63- internal fun <T > MokkeryNamespace.defaultSingleOption (
64+ @InternalMokkeryApi
65+ public fun <T > MokkeryOptionsNamespace.defaultSingleOption (
6466 type : MokkeryOptionType <T >,
6567 description : String ,
6668 defaultValue : T ,
6769): MokkeryOptionPropertyDelegateProvider <T > = option(
6870 type = type,
6971 description = description,
70- defaultValue = defaultValue,
72+ defaultValues = listOf ( defaultValue) ,
7173 required = false ,
7274 allowMultipleOccurrences = false ,
7375)
7476
75-
76- internal fun <T > MokkeryNamespace .option (
77+ @InternalMokkeryApi
78+ public fun <T > MokkeryOptionsNamespace .option (
7779 type : MokkeryOptionType <T >,
7880 description : String ,
79- defaultValue : T ? ,
81+ defaultValues : List < T > ,
8082 required : Boolean ,
8183 allowMultipleOccurrences : Boolean ,
8284): MokkeryOptionPropertyDelegateProvider <T > = PropertyDelegateProvider { container, it ->
@@ -86,13 +88,14 @@ internal fun <T> MokkeryNamespace.option(
8688 required = required,
8789 allowMultipleOccurrences = allowMultipleOccurrences,
8890 type = type,
89- defaultValue = defaultValue ,
91+ defaultValues = defaultValues ,
9092 )
9193 container + = option
9294 ReadOnlyProperty { _, _ -> option }
9395}
9496
95- internal typealias MokkeryOptionPropertyDelegateProvider <T > = PropertyDelegateProvider <
97+ @InternalMokkeryApi
98+ public typealias MokkeryOptionPropertyDelegateProvider <T > = PropertyDelegateProvider <
9699 MokkeryOptionsContainer ,
97100 ReadOnlyProperty <Any ?, MokkeryOption <T >>
98101 >
0 commit comments