Class MixpanelFlagVariant

java.lang.Object
com.mixpanel.android.mpmetrics.MixpanelFlagVariant

public class MixpanelFlagVariant extends Object
Represents the data associated with a feature flag variant from the Mixpanel API. This class stores the key and value of a specific variant for a feature flag. It can be instantiated either by parsing an API response or by creating a fallback instance.
  • Field Details

    • key

      @NonNull public final String key
      The key of the feature flag variant. This corresponds to the 'variant_key' field in the Mixpanel API response. It cannot be null.
    • value

      @Nullable public final Object value
      The value of the feature flag variant. This corresponds to the 'variant_value' field in the Mixpanel API response. The value can be of type Boolean, String, Number (Integer, Double, Float, Long), JSONArray, JSONObject, or it can be null.
  • Constructor Details

    • MixpanelFlagVariant

      public MixpanelFlagVariant(@NonNull String key, @Nullable Object value)
      Constructs a FeatureFlagData object when parsing an API response.
      Parameters:
      key - The key of the feature flag variant. Corresponds to 'variant_key' from the API. Cannot be null.
      value - The value of the feature flag variant. Corresponds to 'variant_value' from the API. Can be Boolean, String, Number, JSONArray, JSONObject, or null.
    • MixpanelFlagVariant

      public MixpanelFlagVariant(@NonNull String keyAndValue)
      Constructs a FeatureFlagData object for creating fallback instances. In this case, the provided keyAndValue is used as both the key and the value for the feature flag data. This is typically used when a flag is not found and a default string value needs to be returned.
      Parameters:
      keyAndValue - The string value to be used as both the key and the value for this fallback. Cannot be null.
    • MixpanelFlagVariant

      public MixpanelFlagVariant(@NonNull Object value)
      Constructs a FeatureFlagData object for creating fallback instances. In this version, the key is set to an empty string (""), and the provided value is used as the value for the feature flag data. This is typically used when a flag is not found or an error occurs, and a default value needs to be provided.
      Parameters:
      value - The object value to be used for this fallback. Cannot be null. This can be of type Boolean, String, Number, JSONArray, or JSONObject.