interface RemoteFeatureFlagProvider {
fun fetchFullConfig(useNetwork: Boolean)
fun <T> getFeatureFlag(key: String, type: Class<T>): T
}
inline fun <reified T> RemoteFeatureFlagProvider.get(key: String): T {
return getFeatureFlag(key, T::class.java)
}
is there a way to hide
fun <T> getFeatureFlag(key: String, type: Class<T>): T
from being accessed ? I want the users to use only extension function so that they can directly use generics instead of passing
Foo::class.java
in the interface method
Jeevan Deep Singh
10/21/2024, 11:18 AM
I have an internal implementation for this. so I thought of casting inside the extension but I cannot access non-public class's method as well in the extension method
p
phldavies
10/21/2024, 12:17 PM
You can mark the internal method as @PublishedAPI and expose it through a public inline method
j
Jeevan Deep Singh
10/21/2024, 12:55 PM
The impl class is marked as
internal
so i cannot access that method through a public inline method 😕
s
Szymon Jeziorski
10/21/2024, 1:25 PM
@Jeevan Deep Singh
@PublishedApi
allows you to call internal classes/members from public inline functions: some site with example