main.wisp.feature.FeatureFlag.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wisp-feature Show documentation
Show all versions of wisp-feature Show documentation
a module containing feature flag helpers
The newest version!
package wisp.feature
sealed interface FeatureFlag {
/**
* Feature name of the feature flag
*/
val feature: Feature
/**
* Unique primary key for the entity the flag should be evaluated against.
*/
val key: String
/**
* The attributes of this feature flag, provided during flag evaluation
*/
val attributes: Attributes
get() = Attributes()
}
interface StringFeatureFlag : FeatureFlag
interface BooleanFeatureFlag : FeatureFlag
interface IntFeatureFlag : FeatureFlag
interface DoubleFeatureFlag : FeatureFlag
/**
* A Enumeration feature flag, when evaluated returns [T]
*/
interface EnumFeatureFlag> : FeatureFlag {
val returnType: Class
}
/**
* 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 {
* override val feature = Feature("payment-configuration-feature")
* override val key = customerId
* override val attributes = Attributes()
* .with("extraAttribute", extraAttribute)
* override val returnType = PaymentConfiguration::class
* }
* ```
*/
interface JsonFeatureFlag : FeatureFlag {
val returnType: Class
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy