Gasan
12/01/2025, 10:09 AMclass MyClass(val myProperty: Boolean|MyType) . The type of myProperty is a union of Boolean and MyType types. That is, myProperty value can be one of those types.CLOVIS
12/01/2025, 10:11 AMGasan
12/01/2025, 10:14 AMsome_feature: true if they want to enable that feature with default parameters, or my_feature: { prop1: value1} if they want to enable the feature and provide feature configuration.Gasan
12/01/2025, 10:15 AMclass Settings(val feature: Boolean|FeatureConfig)Tgo1014
12/01/2025, 11:52 AMclass MyClass(
val flag1: Boolean,
val flag2: Boolean,
val flag3: String,
) {
constructor() : this(flag1 = false, flag2 = false, flag3 = "")
}
MyClass() or MyClass(flag1 = true, flag2 = false, flag3 = "test")
or simply just have the default values filled in, and the user can customize just the ones they want:
class MyClass(
val flag1: Boolean = false,
val flag2: Boolean = false,
val flag3: String = "",
)
MyClass() or MyClass(flag2 = true)CLOVIS
12/01/2025, 1:03 PMclass MyClass(
val myProperty: MyType,
) {
constructor(myProperty: Boolean) : this(MyType(myProperty))
}
The key is: do you care that the user specified a boolean?
Most likely, no. The boolean is here for convenience during creation, but after that it's pointless. You probably don't want to write if (myProperty is Boolean) … else if (myProperty is MyType) each time you want to use the property.
Thus, the boolean should only appear in the constructor, and after that the property is the type.Gasan
12/01/2025, 1:03 PMCoty Saxman
12/02/2025, 3:04 AMComplicatedConfigurable(userOptions = UserOptions.DEFAULT, legacyLogin = LegacyLogin.DISABLED, regionSettings = RegionSettings(getUserRegion()))
Some code like this would be an example of having one feature 'enabled' (passing 'true' in your example), one 'disabled' (false), and one manually configured.CLOVIS
12/02/2025, 8:09 AM