Class FeatureFlagOptions.Builder

java.lang.Object
com.mixpanel.android.mpmetrics.FeatureFlagOptions.Builder
Enclosing class:
FeatureFlagOptions

public static class FeatureFlagOptions.Builder extends Object
Builder for creating FeatureFlagOptions instances.

Default values:

  • enabled = false
  • context = empty JSONObject
  • prefetchFlags = true
  • Constructor Details

    • Builder

      public Builder()
    • Builder

      public Builder(FeatureFlagOptions source)
      Creates a Builder pre-populated with values from an existing FeatureFlagOptions.
      Parameters:
      source - The FeatureFlagOptions to copy values from.
  • Method Details

    • enabled

      public FeatureFlagOptions.Builder enabled(boolean enabled)
      Enables or disables feature flags.
      Parameters:
      enabled - true to enable feature flags, false to disable.
      Returns:
      This Builder instance for chaining.
    • context

      public FeatureFlagOptions.Builder context(@Nullable org.json.JSONObject context)
      Sets the context used for evaluating feature flags.

      The provided JSONObject is defensively copied to prevent external mutation.

      Parameters:
      context - A JSONObject containing key-value pairs for the feature flags context, or null for an empty context.
      Returns:
      This Builder instance for chaining.
    • prefetchFlags

      public FeatureFlagOptions.Builder prefetchFlags(boolean prefetchFlags)
      Controls whether feature flags are automatically fetched on the first app foreground event.

      Set to false if you want to manually control when flags are loaded (e.g., by calling getFlags().loadFlags() yourself).

      Parameters:
      prefetchFlags - true to prefetch on first foreground, false to disable prefetching.
      Returns:
      This Builder instance for chaining.
    • build

      public FeatureFlagOptions build()
      Builds and returns a FeatureFlagOptions instance with the configured settings.
      Returns:
      A new FeatureFlagOptions instance.