Skip to content

Commit 3818a11

Browse files
committed
Use Lazy and ktlint
Signed-off-by: penguindan <[email protected]>
1 parent 8d8cbec commit 3818a11

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

kotlin-sdk/src/commonMain/kotlin/dev/openfeature/kotlin/sdk/multiprovider/MultiProvider.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ class MultiProvider(
5353

5454
// TODO: Support hooks
5555
override val hooks: List<Hook<*>> = emptyList()
56-
private val childFeatureProviders: List<ChildFeatureProvider> = providers.toChildFeatureProviders()
56+
private val childFeatureProviders: List<ChildFeatureProvider> by lazy {
57+
providers.toChildFeatureProviders()
58+
}
5759

5860
// Metadata identifying this as a multiprovider
5961
override val metadata: ProviderMetadata = object : ProviderMetadata {
6062
override val name: String? = MULTIPROVIDER_NAME
61-
override val originalMetadata: Map<String, ProviderMetadata> = constructOriginalMetadata()
63+
override val originalMetadata: Map<String, ProviderMetadata> by lazy {
64+
constructOriginalMetadata()
65+
}
6266

6367
private fun constructOriginalMetadata(): Map<String, ProviderMetadata> {
6468
return childFeatureProviders.associate { it.name to it.metadata }
@@ -157,6 +161,7 @@ class MultiProvider(
157161
} else {
158162
OpenFeatureStatus.Error(event.error)
159163
}
164+
160165
else -> error("Unexpected event $event")
161166
}
162167

kotlin-sdk/src/commonTest/kotlin/dev/openfeature/kotlin/sdk/helpers/RecordingBooleanProvider.kt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,35 @@ class RecordingBooleanProvider(
4040
return behavior()
4141
}
4242

43-
override fun getStringEvaluation(key: String, defaultValue: String, context: EvaluationContext?): ProviderEvaluation<String> {
43+
override fun getStringEvaluation(
44+
key: String,
45+
defaultValue: String,
46+
context: EvaluationContext?
47+
): ProviderEvaluation<String> {
4448
throw UnsupportedOperationException()
4549
}
4650

47-
override fun getIntegerEvaluation(key: String, defaultValue: Int, context: EvaluationContext?): ProviderEvaluation<Int> {
51+
override fun getIntegerEvaluation(
52+
key: String,
53+
defaultValue: Int,
54+
context: EvaluationContext?
55+
): ProviderEvaluation<Int> {
4856
throw UnsupportedOperationException()
4957
}
5058

51-
override fun getDoubleEvaluation(key: String, defaultValue: Double, context: EvaluationContext?): ProviderEvaluation<Double> {
59+
override fun getDoubleEvaluation(
60+
key: String,
61+
defaultValue: Double,
62+
context: EvaluationContext?
63+
): ProviderEvaluation<Double> {
5264
throw UnsupportedOperationException()
5365
}
5466

55-
override fun getObjectEvaluation(key: String, defaultValue: Value, context: EvaluationContext?): ProviderEvaluation<Value> {
67+
override fun getObjectEvaluation(
68+
key: String,
69+
defaultValue: Value,
70+
context: EvaluationContext?
71+
): ProviderEvaluation<Value> {
5672
throw UnsupportedOperationException()
5773
}
5874
}

0 commit comments

Comments
 (0)