Json Feature Flag
A JSON feature flag, when evaluated returns T.
It is expected that a Moshi type adapter is registered for T.
Example definition:
// Step 1: Define the object we expect to get from the JSON flag
data class PaymentConfiguration(
val fraudulent: Boolean,
val vipTreatment: Boolean,
val specialDescription: String
)
// Step 2: Define the feature flag
data class PaymentConfigurationFeature(
// Put the `key` and `attributes` here
val customerId: String,
val extraAttribute: String
) : JsonFeatureFlag<PaymentConfiguration> {
override val feature = Feature("payment-configuration-feature")
override val key = customerId
override val attributes = Attributes()
.with("extraAttribute", extraAttribute)
override val returnType = PaymentConfiguration::class
}Content copied to clipboard