Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/featureflag/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ plugins {
android {
namespace = "net.thunderbird.core.featureflag"
}

kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.androidx.annotation)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@file:JvmName("FeatureFlagProviderCompat")

package net.thunderbird.core.featureflag.compat

import androidx.annotation.Discouraged
import net.thunderbird.core.featureflag.FeatureFlagKey
import net.thunderbird.core.featureflag.FeatureFlagProvider
import net.thunderbird.core.featureflag.FeatureFlagResult
import net.thunderbird.core.featureflag.toFeatureFlagKey

/**
* Provides a feature flag result based on a string key, primarily for Java compatibility.
*
* This function acts as a bridge for Java code to access the Kotlin-idiomatic `provide`
* function that expects a [FeatureFlagKey], as value classes are not compatible with Java
* code.
*
* **Note:** This function is discouraged for use in Kotlin code. Prefer using the
* [FeatureFlagProvider.provide(key: FeatureFlagKey)][FeatureFlagProvider.provide]
* function directly in Kotlin.
*
* @receiver The [FeatureFlagProvider] instance to query.
* @param key The string representation of the feature flag key.
* @return The [FeatureFlagResult] corresponding to the given key.
*/
@Discouraged(message = "This function should be only used within Java files.")
fun FeatureFlagProvider.provide(key: String): FeatureFlagResult {
return provide(key.toFeatureFlagKey())
}